|
3. Logical judgment
all(iterable) |
1. When all the elements in the set are true, it is True 2. In particular, if it is an empty string, it returns True |
any(iterable) |
1. When one element in the set is true Is true 2. In particular, if it is an empty string, it returns False |
cmp(x, y) |
If x < y, a negative number is returned; x == y, returns 0; x > y, returns a positive number |
4. Reflection
callable(object) |
Check whether the object object is callable 1. The class can be called 2. The instance cannot be called Unless the __call__ method is declared in the class |
##classmethod() | 1. Annotation is used to indicate that this method is a class method2. Class Methods can be called by classes or instances 3. Class methods are similar to static methods in Java 4. There is no self parameter required in class methods
|
compile(source, filename, mode[, flags[, dont_inherit]]) | Compile source into code or AST object. Code objects can be executed via the exec statement or evaluated with eval(). 1. Parameter source: string or AST (Abstract Syntax Trees) object. 2. Parameter filename: the name of the code file. If the code is not read from the file, some identifiable values will be passed. 3. Parameter model: Specify the type of compiled code. Can be specified as 'exec', 'eval', 'single'. 4. Parameters flag and dont_inherit: These two parameters will not be introduced for the time being.
|
dir([object]) | 1. Without parameters, return the current List of variables, methods and defined types within the scope; 2. When taking parameters, return the list of properties and methods of the parameters. 3. If the parameter contains the method __dir__(), this method will be called. When the parameter is an instance. 4. If the parameter does not contain __dir__(), this method will collect parameter information to the maximum extent
|
delattr(object, name) | Delete the object object Attribute named name |
eval(expression [, globals [, locals]]) | Calculate the value of expression expression |
execfile(filename [, globals [, locals]]) | The usage is similar to exec(), except that the parameter filename of execfile is the file name, and the parameter of exec is a string. |
filter(function, iterable) | Construct a sequence, which is equivalent to [item for item in iterable if function(item)]1. Parameter function : A function whose return value is True or False, which can be None 2. Parameter iterable: sequence or iterable object |
getattr(object, name [, defalut]) |
Get the attributes of a class |
globals() |
Returns a dictionary describing the current global symbol table |
hasattr(object, name) |
Judge object object Whether to include the attribute named name |
hash(object) |
If the object object is a hash table type, return the hash value of the object object |
id(object) |
Returns the unique identifier of the object (memory identifier) |
isinstance(object, classinfo) |
Determine whether object is an instance of class |
issubclass(class, classinfo) |
Determine whether it is a subclass |
##len( s) | Return the collection length |
locals() | Return the current variable list |
map (function, iterable, ...) | Traverse each element and perform the function operation |
memoryview(obj) | Return a memory image type The object of |
next(iterator[, default]) | is similar to iterator.next() |
##object()
Base class |
|
property([fget[, fset[, fdel[, doc]]]])
Wrapper class for property access, After setting, you can access the setter and getter through c.x=value, etc. |
|
reduce(function, iterable[, initializer])
Merge operation, starting from the first The first two parameters, then the results of the first two are combined with the third one for processing, and so on |
|
reload(module)
Reload module |
|
setattr(object, name, value)
Set attribute value |
|
repr(object)
will An object is transformed into a printable format |
|
slice()
|
|
staticmethod
Declare static Method is an annotation |
|
super(type[, object-or-type])
references the parent class |
|
type (object)
Returns the type of the object |
|
vars([object])
Returns the object's variables, if there are no parameters and dict() The method is similar to |
|
bytearray([source [, encoding [, errors]]])
Returns a byte array | 1. If source is an integer, return An initialization array with a length of source; 2. If source is a string, convert the string into a byte sequence according to the specified encoding; 3. If source is an iterable type, the element must be [ 0,255]; 4. If the source is an object consistent with the buffer interface, this object can also be used to initialize bytearray.
|
zip([iterable , ...])
is approximately equal to a zipper, which is to arrange the elements in the two lists one by one |
|
5. IO operation
file(filename [, mode [, bufsize]])
Constructor of file type, which is used to open a file. If When the file does not exist and the mode is write or append, the file will be created. Adding 'b' to the mode parameter will operate on the file in binary form. Adding '+' to the mode parameter will allow simultaneous read and write operations on the file | 1. Parameter filename: file name. 2. Parameter mode: 'r' (read), 'w' (write), 'a' (append). 3. Parameter bufsize: If it is 0, it means no buffering. If it is 1, it means line buffering. If it is a number greater than 1, it means the size of the buffer.
|
input([prompt])
Get user input | It is recommended to use raw_input, because this function will not capture user input errors
|
open(name[, mode[, buffering]])
Open a file | What is the difference from file? It is recommended to use open
|
print
Print function |
|
raw_input([prompt])
Set input , the input is processed as a string |
|
|