列表和字符串
添加元素
list.append(obj)+元素位置(下标) list.index(obj)
string.find(obj) list1 = ['a', 'b', 'c', 'd', 'e', 'f', 'a', 'a', 's']
string1 = 'abcdefaas' 元素a出现的次数 list1.count('a')
string1.count('a',0,len(s))
切片
list1[::2] 输出:['a', 'c', 'e', 'a', 's']
string1[::2] 输出: 'aceas'
成员函数判断
‘a’ in list1 输出:True‘a’ in string1 输出:True逆转
索引(字符串可以被遍历、索引、切片)
s='3ewrewr'
for i in s:
print(i)
break
print(s[3])
print(s[2:])
返回:
3
r
wrewr