Format Python
Format
String Format
print("I'm %s. I'm %d year old" % ('Vamei', 99))
print ('this is %s %%') (% date) # %% to print %
- s.strip() .lstrip() .rstrip(',') remove empty space, and special words
Format type
- print type(aaa) # print type of aaa variable
- print len(aaa) # print length
Change format
a = float(b) change to type float
Module String
Replace
import string
a = 'abcde'
b = string.replace(a, 'ab', '', 1)
print b