Chapter III1. String formatting >>>format= "Hello%s%s World" >>>values= (' World ', ' hot ') >>>print format% values # You can also receive a single string, or you can use%f%d, similar to C's printf, to match multiple parameters with parentheses >>> '%s plus%s equals%s '% (1,1,2)
>>> '%010.2f '% pi ' 0000000003.14 ' represents altogether 10 seats 0, integers, decimal points, fractional parts
2. Operation of the string find or find (' xx ', start,end) str.find (' xxx ') #返回字符串的位置
Join, Split's inverse method. For example s=[1,2,3,4] flag= ', ' flag.join (s), 1,2,3,4
Replace (SOURCE,XXXX) replacement
3. Conversion table Table=maketrans (' Ca ', ' BD ') word= ' HelloWorld '. Translate (table)
Fourth ChapterThis part of the content is written less than a log1. Creation of dictionaries>>>items={' Alice ': ' 1234 ', ' bob ': ' 4567 '}{} is an empty dictionary2.dict functiond=dict (Two-dollar key-value team) such as [(' A ', 1 '), (' B ', 2)]3. Basic OperationLen (d)D[k]del D[k]K in D4. Formatting stringstemplate= ' Print template% {' title ': ' Hello '}5. The method of the dictionaryClear ClearRemoveCopy # y=x.copy ()deep copy: Deepcopy # dc=deepcopy (d)The Get access dictionary does not error, and setting does not exist when the value get (key, ' Error infor ') Fromkeys Create an empty dictionary, only the keys such as {}.fromkeys ([' Name ', ' age ']) has_keyitems No order iteritems return iterator pop (key) Delete Popitem Delete last update
most of the functions do not need to memorize, use the time to turn over notes, separate check usage, used when familiar.
Python reading notes-chapter III, chapter Four