Python data type-remove blank strings, strip (), including spaces, tab keys, line breaks
>>> name = " Frank ">>> name.strip()'Frank'
String segmentation, split ("separator"), grouped into a list
>>> name = "Apple, banbana, orice">>> name.split(",")['Apple', ' banbana', ' orice']>>>
String join ("connector ")
>>> name = ['Frank', 'Marlon', 'Lee']>>> "|".join(name)'Frank|Marlon|Lee'
Determines whether the space is "in" in the substring"
>>> name = "Frank Bain">>> '' in nameTrue>>> "L" in nameFalse>>>
Two string formatting formats
# First expression method >>> msg = "Hello {name}, your age is {age}" >>> msg. format (name = "Frank", age = 24) 'Hello Frank, your age is 24' >>># Method 2, note that index starts from 0 >>> msg = "Hello {0}, your age is {1}, sex is {2}" >>> msg. format ("Frank", 24, "man") 'hellofrank, your age is 24, sex is Man' >>>
String judgment
>>> name = "Frank">>> name.upper()'FRANK'>>> name.lower()'frank'>>> name.startswith("F")True>>> name.endswith("k")True>>> name.endswith("a")False