1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 #in 的用法(它在不在這個字符串里面) 4 #ret(返回,譯音:ruai特) 5 #給s賦值為字符串“Alex SB”, ret的賦值等於,計算s變量里面有沒有字符串“SB”如果在s變量中找到了字符串“SB”返回為True,否則返回為False 6 #粒度不一樣,字符串粒度小,最小單位為一個字符 7 s = "Alex SB" 8 ret = "SB" in s 9 print(ret) 10 # not in 與in的返回值相反 11 #粒度不一樣,元組粒度大,最小單位為一個字符串 12 li = ["alex", "eric","rain"] 13 ret = "alex" not in li 14 print(ret)
