标签:使用字符串 print int string test index class span dex
1 str = "string test string test" 2 find1 = "str" 3 find2 = "test" 4 print(find1 in str) # True 5 print(find1 not in str) # False
偷偷说一句:in不只是在字符串中可以使用哦!期待后面的教程叭
1 str = "string test string test" 2 find1 = "str" 3 find2 = "test" 4 # find 5 print(str.find(find1)) # 0 6 print(str.find(find2)) # 7 7 8 # rfind 9 print(str.rfind(find1)) # 12 10 print(str.rfind(find2)) # 19 11 12 # index 13 print(str.index(find1)) # 0 14 print(str.index(find2)) # 7 15 16 # rindex 17 print(str.rindex(find1)) # 12 18 print(str.rindex(find2)) # 19 19 20 # count 21 print(str.count(find1)) # 2 22 print(str.count(find2)) # 2
标签:使用字符串 print int string test index class span dex
原文地址:https://www.cnblogs.com/poloyy/p/12207464.html