Introduction to python: the usage of in (it is not in this string)

1  # !/usr/bin/env python 
2  # -*- coding:utf-8 -*- 
3  # usage of in (it is not in this string) 
4  # ret (return, transliteration: ruai special) 
5  # Assign s the string "Alex SB", the assignment of ret is equal to, and calculate whether there is a string "SB" in the s variable. If the string "SB" is found in the s variable, it returns True, otherwise it returns 
False 6  #granularity Not the same, the string granularity is small, the minimum unit is one character 
7 s =   " Alex SB " 
8 ret = " SB "  in s
 9  print (ret)
 10  # not in is opposite to the return value of in 
11  # granularity is different, yuan The group granularity is large, the minimum unit is a string 
12 li = [ "alex", "eric","rain"]
13 ret = "alex" not in li
14 print(ret)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324507897&siteId=291194637