A collection of
1. Characteristics: random and natural de-emphasis, the format is {}
2. effect:
(1) deduplication
(2) the relationship test
3. Callable functions (on the common list of operations)
( 1 ) on the intersection: A.intersection (B)
( 2 ) take the union: A.union (B)
(3)取差集:A.difference(B) in A not in B
( 4 ) whether the subset: A.issubset (B) returns True or False
4. Operators
( 1 ) Cross-: &
( 2 ) and: |
( 3 ) Poor: -
( 4 ) symmetric difference: ∧ -
The deletions check change
Second, file operations
1. turn on
(1) file path
(2) operating authority: R & lt , read-only; W , only write (create a new file); A , is added; R & lt + , read; W + , write (create a new file); ab & , RB , WB : binary format; rU : identify different line breaks
(3) encoding format
2. operating
(1) the Read () : All Reading
(2) Readline () : Read one row
(3) readlines () : All read and converted into a list (due to be written to memory, so only suitable for small files);
Optimization loop: for f in Line: .......
(4) the Write () : write to file
(. 5) Tell () : returns the file operation position "cursor" in
(. 6) the Seek () : returns the cursor to the designated position (one unit character)
(7) Truncate () : truncated, beginning of the file to the specified location
3. shut down
(. 1) the Close () : Close file operation
(2) the Flush () : confirm the contents of the cache written to a file
(. 3) With : automatically closes the file: with Open ( 'log', 'R & lt') AS F:
Third, the character encoding
Fourth, the function
1. The difference between functions and procedures
2. The role of the function:
(1) reducing the duplication of code
(2) can be extended
(3) to maintain data consistency
3. return value
(1) 0 : Returns none
(2) 1 : Returns the object
(3)> 1 : Returns tuple (tuple)
(4) Function: returns the memory address
4. parameter
(1) formal and actual parameters: a parameter in the parameter function; arguments: the incoming real parameters
(2) critical parameters
(3) position parameter
(4) Parameter Group: * args ; ** kwargs
5. Variable scope
(1) global variables: variables defined externally; by global changes in the global variable function; lists, dictionaries, sets, classes can be modified within the function
(2) local variables: variables defined in the function;
6. Higher-order functions: functions nested functions
7. Recursive: calls itself
(1) there must be a clear sign of the end
(2) each time you enter a deeper recursion, the scale of the problem should be reduced compared to the previous recursive
(3) is not efficient recursive, recursive hierarchy too much will stack overflow