Python Reading Notes-Chapter 3, chapter 4, python Reading Notes
Chapter 3 1. string formatting >>> format = "hello % s world" >>> values = ('World', 'hot ') >>> print format % values # You can also receive a single string or use the % f % d type. When matching multiple parameters with c's printf, you should use parentheses >>> '% s plus % s equals % s' % (1, 1, 2)
>>> '% 010.2f' % pi '0000000003. 14' indicates a total of 10 seats, 0, integer, decimal point, and decimal part.
2. find or find ('XX', start, end) str. find ('xxx') # Return the position of the string.
The inverse method of join and split. For example, s = [1, 3, 4] flag = ', 'flag. join (s)-> 1, 2, 3, 4
Replace (source, xxxx)
3. Convert table = maketrans ('CA', 'bd ') word = 'helloworld'. translate (table)
In chapter 4, this part is written as less than one log. create a dictionary >>> items = {'Alice ': '000000', 'bob': '000000'} {}. The dictionary is empty. 2. dict function d = dict (Binary key-value Team) for example [('A', 1), ('B', 2)] 3. basic operation len (d) d [k] del d [k] k in d4. format the string template = 'Most functions do not need to be memorized. When using the function, you can flip the notes and check the usage separately. You are familiar with the usage .!!