First of all, before that, I was not a Python player. I was just a user and needed to obtain it. Now, I have to learn and record it carefully. It is called a Python player.
Note: This is obviously not a tutorial, but a note that I understand and record myself.
Python hasFive Standard Data Types:
Numbers (number) String (String) List (List) Tuple (tuples) Dictionary (Dictionary)
NumberThere are four numeric types: int, long, float, complex,
Example: a = 250 # int
B = 12345678910L # long, can also end with lowercase l, but it is easy to confuse, use uppercase L to cool.
C = 0.1 # float
D =-5.32e10 # float,-5.32*10 ^ 10
E = 35.23E-7 # float, 35.23*10 ^-7
F = 2j # complex
G =-1 + 3j # complex
H = 8 + 7e10j # complex
StringIt is a string of digits, letters, and underscores. It is basically the same as C ++.
Str = "pythonissimple"
The subscript still starts from 0, unlike the "cult" of matlab "...
It is very easy to take the substring. It can start directly to the end of the next bit. For example, print str [], the output is iss, that is, the output is left closed and right open.
It can also be used in turn to get it. The author is really cool... For example, print str [-5,-1] outputs impl.
ListIt feels like an array, but a list can be put in everything. Use [] to represent the list
For example, list1 = [1, 2, 'python', 1e-7, 3 + 7i],
List1 [I] is the same as that of c ++. For example, print list1 [2] outputs python
Take the sub-list, like the string to take the sub-string, the parent dictionary or something is like this to take the sub-string.
It is worth mentioning that python has+ ,*The two lists are connected, and how many times are repeated?
For example, I and list2 = ['cpp ', 123, 'java']
Print list1 + list2 is [1, 2, 'python', 1e-07, (3 + 7j), 'cpp ', 123, 'java']
Print list1 * 2 data is [1, 2, 'python', 1e-07, (3 + 7j), 1, 2, 'python', 1e-07, (3 + 7j)]
YuanzuIn my opinion, it is a read-only list, represented by (), that is, tup1 = (1, 'python'), you cannot tup1 [1] = 0, the list is acceptable.
DictionaryIs actually a map ing. The dictionary is identified. A dictionary consists of an index (key) and its corresponding value. If you are familiar with stl, this is simply a truth.
For example, asc2 = {}; asc2 ['a'] = 97, asc2 [98] = 'B'. The result of print asc2 is {'A': 97, 98: 'B '}
In addition, we can also directly use the statement: acs2 = {'A': 97, 98: 'B '}, acs2 ['a'] is used for query. (acs2 ['B'] cannot be used. This is a one-way ing)
Conversion:Int (x), float. long is similar,
Str (x) to a string
List (s), tuple (s) is to convert the sequence s into a list, ancestor.
Chr (x), an integer converted into a single character, acⅱ.
Ord (x), which is inverse to chr
Hex (x), oct (x) 16 forbidden, octal forbidden
Speaking of hexadecimal, I think of one of the C Programming expertsJoke
Why can't programmers tell Halloween and Christmas? (The joke of programmers is really "funny ...)
Because Oct31 = Dec25, Oct is octal, and Dec is decimal. 31 In octal, which is 3*8 + 1 = 25 ..
Just have a fun!