Learn "python core programming" to do a bit of knowledge of the summary, easy to review.
What is the nature of computer language?
A-Z, a-Z, symbols, numbers, and so on are combined into a syntax-compliant string. For compilers and interpreters.
The combination of letters produces a variety of changes in Python. Keyword values, classes, functions, operators, operator ...
1. Variable does not have to be declared, type is not fixed
2.true,false = False,true read out what? True is a bool () class instance
3. Type factory function is python2.2 after the int () bool () and other functions of the data type operation to the object class, return the object instance
4. Three single-lead (three double-cited) is a string constant. Just being able to branch out can also be used to gaze at multiple lines.
5. The string at the beginning of the module, class, and function is the document string, with doc access
6.2<3<6 is 2<3 and 3<6 empathy > 66 = = 66
7.a,b,c=c,b,a Multi-value assignment
8.+=,-=,=, *=,/=, etc. are called incremental assignments.
9. Write more than one sentence in the same line;
10. Floor ———//hehe
11. Floating-point representation in memory is also a binary representation
12.+, * for string connection and repetition
13.[] called the index operator, [:] is called the slice operator
14. The first string is 0. The last string is-1
15. Open Python at the command line but set the number of parameters. Do you know?
16.if expr: ... else: ... if expr: ... elif expr: ... else: ...
17.while Expr: ...
The 18.for loop is actually more like a foreach iterator inside the shell, iterating over the elements. For ... in .....
What will the
for dictionary look like?
19.print, which indicates that there is no line break but there are spaces.
20. Separate print is the output line break
21. What is List parsing? [X**2 for X in range (4)], [x**2 for X in range (4) if not x% 2]
22.try: ... except ...
23. Ability to raise an exception like a throw in Java
24. The function does not return and returns none
25. function def foo (para = True): ... The function can have a default value of
26. How is a static variable of a class defined?
27. In a class, a variable defined by SELF.A is present only in the instantiation, not in the class
28.PEP is what you look for in
29. It is best to indent with four spaces, do not use tabs, cross-platform bad
30. The code inside the module can be a script that runs directly, can also be similar to the library function code
31.python Assignment is a reference assignment, only changes to allocate new memory
32. Multiple assignments x = y = z = 1
33.import ... from * Do not abuse
34.python does not support overloaded labels Even though build-in is not keyword, it is not recommended to use it as a reserved word
35._xxx does not import from module import *, protects members, subclasses can access
private variables in the 36.__xxx class. Subclasses cannot access the
37.if __name__ = = ' __main__ ' to regression or unit test
38. In the file, all the top-level code is run, and the best code in the module is less than
39. Have time to get to know Pyunit
40. All Python objects have three attributes, an identity (ID ()), a type (type ()), and a value of
41. The property is the function, method, data.
Classes, class instances, modules, complex numbers, files, etc. that contain data attributes
42. Standard type (base data type): Integer, Boolean, floating point, plural, string, list, tuple, dictionary
43. Other built-in types: types (Type ()), NULL objects (None), files, collections, Functions (methods), modules, classes
44. The user-created class instance assumes that Nonezero (__nonezero__ ()) or length (__len__ ()) is defined, and the value is 0. Then their boolean value is false.
45.A is b equivalent ID (a) ==id (b), and of course, is not
The variables in 46.python are more like pointers pointing to boxes that load variables. Assigning a new value is like changing a box.
47.del is able to delete references to objects. Reference delete You can no longer use this variable name (reference)
48.10, 017, 0x92 decimal, octal, hex
49. Check the decimal floating point type.
50. String Str1 < str2 with the size of the ASCII value of the string
51. Member operators in and not in
F = ("AAA" #1
"BBB" #2
"CCC") #3
Print F
53.%d,%c,%f these formatted output symbols are called placeholders
54. Original string operator (R/R) print R ' \ n '
The 55.Unicode string operator (u/u), if associated with the original operator. Must be in front of R.
ur ' Hello\nworld '
56. The string is immutable
57. Strings, lists, and tuples collectively referred to as sequences
The 58.sort () function has a return value for the string, and the list changes in the original list. no return value.
59. Use lists to build other data structures, queues and stacks
60. Numbers, strings, and tuples are immutable types
61. Copy Python objects, deep copy and shallow copy
62.P = [:] Slice Copy, list () dict () factory function, copy module copy function are shallow copy
63. There is an interesting example of a "read-only" or a non-variable problem in the copy process
p=[' name ', [' age ', 33]]
m = p[:];n = List (p)
m[0]= ' kids '; n[0]= ' adults '
M[1][1] = 99
I found that the name part of M and N is different, but the list is 99 with the ID () function to find the sequence part is the same, the name part is different.
64. Run a deep copy with Copy.deepcopy ()
65. Non-container type (number. String. Other atomic type objects, codes, types, and Xrange objects) are not copied.
66. Assuming that the tuple variable includes only the atomic type, the deep copy of it will not be made, and the deep copy can only get a shallow copy
67. Most Python objects can be keys, but lists and dictionaries are not hashed and cannot be keyed
68. A class that implements the __hash__ () Special method can also be used as a key
69. Collections can be obtained by set and Frozenset
Very many built-in methods of type 70.python "almost" and operator equivalents
71. Conditional expression x if x < y else y
72.smaller = (x < y and [x] or [y]) [0] Try 1<2 and [1], why is this? It seems that the same as the C language will short-circuit, true and X only to consider the following x can. False and x words x expression is not required to run.
73.while (Count < 9): What is that parenthesis? Understand: A = (2) b = (' 3 ') is a tuple?
The role of 74.pass
75.while and for can use else statements
76. Dictionaries, files can be used with the iterator ITER (SEQ), with for ... in ... The system will actively convert itself
77. Iterators are best not to delete elements when used
78. Classes that implement the __ITER__ () and Next () methods can be used as iterators
79.[(x+1,y+1) for x in range (3) for Y in range (5)]
80. The generator expression is the square that parses the list into parentheses (), feeling like this
81. File Open mode has w r a U + (indicates readable writable) b means binary open
Learn "python core programming" to do a bit of knowledge, easy to review (a)