Developed with the old boy's education in Python [Article 3]: Python functions, old boy python
Set
Unordered, non-repeated, nested.
Function
Create a function:
1. def Keyword: Create a function
2. Function Name
3 ,()
4. Function body
5. return values
Default return value of the return function in the mail function None common parameter default parameter
Note: To specify a default value for a parameter, the parameter must be placed at the end of the parameter list.
Specify parameter dynamic parameters :*
Note: * by default, all input parameters are placed in the tuples, f1 (* li ).
Dynamic parameters: Dictionary (**)
Note: ** by default, all input parameters are placed in the dictionary, f1 (** dic ).
Universal Parameters
Note: the order of * args and ** kwargs cannot be changed.
Use the format function to guess the output of Dynamic Parameters
Note: function parameters pass references.
Global Variables
Note: The global variable must be assigned a value again. You can modify the list or dictionary and cannot assign a value again. Define all global variables in uppercase.
Functions implement login and registration of Three-element operations (three-object operations) lambda expressions built-in functions
Flush:
Readable () to check whether the object is readable, True or False is returned.
Readline () reads only one row of data. When the file size is very large, the memory will not pop up.
Truncate () truncation, data after the pointer is cleared
For loop open file object:
Write the first 10 rows of file 1 to file 2:
Replace a string of the file: