A= ' This is a '
B=a.replace (' A ', ' B ') string substitution
C= ' This is%s%s '% (' my ', ' Apple ')
D= ' This is {} {} '. Format (' My ', ' Apple ')
E= ' This is {1} {0} '. Format (' Apple ', ' my ') formatted output, output order
F= ' This is {whose} {fruit} '. Format (fruit= ' Apple ', whose= ' my ')
G= ' This is% (whose) s% (fruit) s '%{' fruit ': ' apple ', ' whose ': ' My '} Another formatted output, followed by a dictionary that corresponds to the previous key's value%s, defined by the key% after the value
============================
Read file
1, f=open (' filename ', ' W ')
F.write (' This is file ')
F.close
2. F=file (' filename ', ' r ')
F.read (20)
F.seek (0) back to the first position of the file cursor
F.close ()
3. Import Linecache
Linecache.getline (' filename ', line number)
A=linecache.getlines (' filename ')
Print A is stored in the list
Python Basic formatted output