Method string main operations:
= ST 'Hello Kitty'
Print (st.count ( 'L')) # statistical occurrences element
print (st.center (50, '# ')) # centrally
print (st.startswith ( 'he') ) # Analyzing whether a string that begins with
print (st.find ( 't') ) # returns the index
print (st.format (name = 'alex ', age = 37)) # another way formatted output
print ( 'My tLtle'.lower ()) # converted to lower
print (' My tLtle'.upper ()) # uppercase
print ( '\ tMy tLtle \ n'.strip ()) # tabs and left spaces, newline delete
print ( 'My title title'.replace (' itle ',' lesson ', 1)) # integrally replaced, the replacement can specify the location of the string
print (' My title title'.split ( ' i', 1) ) # string, divided, replaced with the specified string, separated
Data type conversion:
1,int <——> str
s = str (int), no conditions
i = int (str), the string conversion must be a number
2,list <——> tuble
list = list(tuple)
tuple = tuple(list)
3,list <——> set
list = list(set)
set = set(list)
4,tuple <——> set
tuple = tuple(set)
set = set(tuple)
5, important conversion,
List to String: List -> str
lst = ["1","2","3"]
print("".join(lst)) #123
6, the string transfer list: str -> list
s = "host1 host2 host3"
print(s.split())#[host1,host2,host3]