while 循环工作中用的较少;主要以for循环为主。
find 与index的区别
# mystr = "hello world and hello python and oyou"
# print(mystr.find('and')) # 12
# print(mystr.find('and', 15, 35)) # 29
# print(mystr.find('ands')) # -1
# 2.index() 如果不在子串中,则报错,,
# print(mystr.index('and')) # 12
# print(mystr.index('and', 15, 32)) # 29
# print(mystr.index('ands', 15, 32)) # 报错
|
|