Python Reading Notes-Chapter 3, chapter 4, python Reading Notes

Source: Internet
Author: User
Tags print format

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 .!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.