<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body {
font-family: "Microsoft YaHei", serif;
}
body, dl, dd, p, h1, h2, h3, h4, h5, h6 {
margin: 0;
}
ol, ul, li {
margin: 0;
padding: 0;
list-style: none;
}
img {
border: none
}
</style>
</head>
<body>
<div id="wrap"></div>
<script>
let str = "啦啦啦德玛西亚";
let arr = str.split("");
console.log(str.indexOf("西亚")); //获取字符在字符串中的位置
console.log(arr.indexOf("德")); //获取元素在数组中的位置
console.log(arr.indexOf("拉")); //找不到返回-1
console.log(arr.indexOf("啦",1)); //可以传第二个值 就是从哪开始找
console.log(arr.lastIndexOf("啦")); //从最后边开始找
</script>
</body>
</html>
Python3Turtle