I. digress
Previously, I vowed that this series of notes would be completed in May, but now it is almost impossible. Why is this happening? I have reflected on the following:
1. The learning route is not firm:
Python, Django, mysql, and jquery later, disrupt the original plan.
2. Unclear objectives:
I don't know how much I want to achieve, what functions I want to implement, and so on, which leads to poor behaviors such as decentralization and perfunctory.
The next step is the time for correction. We still need to manage ourselves and encourage ourselves.
Ii. Sequence type
Contains the string, list, and ancestor. The modes are the same. For example:
1. member relationship operator (in/not in)
2. Slice
S = [,] print s [:-1] # The subscript range is []. If the step size is-1, all values are removed from the back (4, including 4, output: [4, 3, 2, 1] print s [:-2] # The subscript range is [0, 0], and the step size is-2, then from the back (4, including 4) skip Step 2 and output: [4, 2] print s [:] # subscript range: [0, 0]. The step size is 0, then the previous (1, including 1) extract all data from the backend. Output: [1, 2, 3, 4] print s [: 2] # subscript range: [0, 0]. If the step is 2, (1) skip the two-bit truncation and output: [1, 3] print s [] # The subscript range is []. If the step size is 2, the subscript is 1 (2) when the subscript is 4 (4), skip the two-bit cut. Output: [2, 4]
Flexible use.
Iii. Sequence type built-in functions
For example, list (), tuple (), str () type conversion is actually a factory function. The result of shortest copy is not a real face change (conversion ).
Note that applying list () and tuple () on the string type often cannot obtain the desired result.
List of built-in functions of sequence types:
Cmp (), len (), max (), min (), enumerate (), zip (),
Iv. Unicode string
1 >>> 'hello'+u' '+'world'2 u'hello world'
5. built-in methods for string types
1. Uncommon string modules
1 >>> import string 2 >>> string.uppercase 3 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 4 >>> string.lowercase 5 'abcdefghijklmnopqrstuvwxyz' 6 >>> string.whitespace 7 '\t\n\x0b\x0c\r ' 8 >>> string.digits 9 '0123456789'10 >>> string.punctuation11 '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
Open the string. py module as follows:
.......................................# Some strings for ctype-style character classificationwhitespace = ' \t\n\r\v\f'lowercase = 'abcdefghijklmnopqrstuvwxyz'uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'letters = lowercase + uppercaseascii_lowercase = lowercaseascii_uppercase = uppercaseascii_letters = ascii_lowercase + ascii_uppercasedigits = '0123456789'hexdigits = digits + 'abcdef' + 'ABCDEF'octdigits = '01234567'punctuation = """!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""printable = digits + letters + punctuation + whitespace# Case conversion helpers.......................................
Not commonly used. Many functions can be simulated by yourself.
2. built-in functions
Join/split: http://www.cnblogs.com/BeginMan/archive/2013/03/21/2972857.html