Address: http://docs.python.org/library/functions.html
Translation:
Python provides many built-in functions. The following table lists and describes the functions in alphabetical order.
ABS (X)
Returns the absolute value of a number. The parameter can be a common integer, a long integer, or a floating point number. If the parameter is a plural value, its value is returned. For example, if a = x + yi, ABS (A) = SQRT (x ^ 2 + y ^ 2 ).
All (iterable)
Returns true if all elements in a programmable object are true values. Equivalent:
Def all (iterable ):
For element in iterable:
If not element:
Return false
Return true
This function is added in version 2.5.
Any (iterable)
Returns true as long as one element in a programmable object is true. It is equivalent:
Def any (iterable ):
For element in iterable:
If element:
Return true
Return false
This function is added in version 2.5.
Basestring ()
(Note: basestring is a callable object .) Basestring is the parent class of STR and Unicode. It is an abstract class and cannot be called or instantiated directly. However, it can be used to test whether an object is a STR or Unicode instance: isinstance (OBJ, basestring), equivalent to isinstance (OBJ, (STR, Unicode )).
This function is added in Version 2.3.
Bin (X)
Converts an integer to a binary string. The result is a valid Python expression. If parameter X is not an integer object (INT object), it must define the _ index _ () method and return an integer.
This function is added in version 2.6.
Bool ([x])
Use standard truth testing procedure to convert a value to a Boolean value. If the parameter X is omitted or false (for example, 0, Null String, none), false is returned; otherwise, true is always returned. Bool is also a type, which is a subclass of the int type. However, it cannot be a subclass of the bool type. It has only two instances: true and false.
This function is added in Version 2.21.
Changed in Version 2.3: If no parameter is input, the function returns false.
Callable (object)
If the parameter object is callable, true is returned; otherwise, false is returned. Even if the function returns true, calling this object may still fail. However, if false is returned, the call object will certainly fail. Note: All classes are callable (a new instance is returned by calling the class ). Instances that define the _ call _ () method are callable.
CHR (I)
Converts an integer whose asⅱ code is I to a string that contains only one character. For example, CHR (97) returns the string 'A '. Parameter I must be in the range of 0 to; otherwise, a valueerror exception is triggered. The corresponding function is ord (c), which converts characters to integers. You can also refer to unichr ().
Classmethod (function)
This function returns a class method.
The class method explicitly receives the first parameter as the class type, just as the instance method receives the first parameter as a reference to the current instance. You can use the following syntax to define a class method:
Class C:
@ Classmethod
Def F (CLS, arg1, arg2 ,...):...
@ Classmethod is a function modifier-you can query more information about Function Definition descriptions in function definitions.
You can call class methods through classes (such as C. F () or instances (such as C (). F. If the class method of the parent class is called in the derived class, the derived class object will be passed into the class method as the first parameter.
Python class methods are different from static methods in C ++ or Java. You can learn about staticmethod in this chapter.
For more information about class methods, see the standard type hierarchy.
This function is added in version 2.2.
Modification made in version 2.4: added support for function decoration syntax.
CMP (x, y)
Compare two objects and return an integer based on the comparison result. If x <Y, a negative number is returned. If x> Y, a positive number is returned. If x = Y, 0 is returned.
Compile (source, filename, mode [, flags [, dont_inherit])
Compile the source code into a code object or ast object. You can execute code objects using exec statements or evaluate values using eval. The source parameter can be a string or ast object. For more information about the ast object, refer to the ast module documentation.
The mode parameter specifies the code compilation mode. It can be:
"EXEC": code segment
"Eval": a single expression
"Single": a single interactive statement
Optional flags and dot_inherit parameters control future statements that affect code compilation. The default values of both parameters are 0,
Complex ([real [, imag])
Create a plural value of real + imag * j, or convert a string or number into a plural value. If the first parameter is a string, it will be parsed as a complex number, and the second parameter cannot be provided. The second parameter cannot be a string. Each parameter can be of any numeric type (including the plural type ). The default value of imag is 0. If both parameters are omitted, return 0j.
Delattr (object, name)
A parameter is an object and a string. The string must be the name of the object property. The function deletes the attributes of an object. For example, delattr (X, "foobar") is equivalent to the statement del X. foobar.
The corresponding function of delattr is setattr, which is used to set object attributes.
Dict ([Arg])
Create a dictionary object. The optional parameter Arg is used to initialize dictionary items.
The dictionary type is described in the mapping types-dict chapter. For more information about other containers, see the list, set, tuple, and collections modules.
Dir ([object])
If the parameter is omitted, the function returns a list of variables in the local area. If the parameter is not omitted, the function tries to save all valid property names of the parameter object to the list and return to the list.
If the object defines the _ DIR _ () method, the method is called and the attribute list is returned. Objects are allowed to customize the properties of objects returned by Dir () by implementing the _ getattr _ () and _ getattribute _ () methods.
If the object does not define _ DIR _ (), Dir () tries to use the _ dict _ attribute of the object (if _ dict _ is defined __) and get information in the object type. The results returned by Dir () do not need to be complete. If the object defines the _ getattr _ () method, the results may be inaccurate.
The default Dir () implementation may have different behaviors for different types of objects. It tries to obtain more relevant information, instead of all information:
If the object is a module object, the result list contains the names of attributes defined in all modules.
If the object is a type or class object, the result list contains all the property names of the type, including inherited from the parent class.
Otherwise, the result list contains all the property names of the object, the property names of the object type, and all the property names of the parent class.
The result list is saved alphabetically by the attribute name.
>>> Import struct
>>> Dir () # doctest: + skip
['_ Builtins _', '_ Doc _', '_ name _', 'struct ']
>>> Dir (struct) # doctest: + normalize_whitespace
['Struct ',' _ builtins _ ',' _ Doc _ ',' _ file _ ',' _ name __',
'_ Package _', '_ other ache', 'calcsize', 'error', 'package', 'pack _ ',
'Unpackage', 'unpack _ from']
>>> Class Foo (object ):
... Def _ DIR _ (Self ):
... Return ["kan", "Ga", "roo"]
...
>>> F = Foo ()
>>> Dir (f)
['Ga ', 'kan', 'roo']
Divmod (A, B)
Receive two numbers (except the plural) as the parameter and return a pair of values: quotient and remainder. Different types of operands are calculated based on the binary arithmetic algorithm. For common integers and long integers, the result is: (a/B, a % B ). For floating point numbers, the result is: (Q, a % B), where q = math. Floor (a/B) If q <1, q = 1. In any case, Q * B + A % B is always very close to a. If a cannot divide B, then: 0 <= ABS (a % B) <ABS (B ).
Modified in Version 2.3: the plural value is not used as the parameter.
Enumerate (sequence [, start = 0])
Returns an enumerate object. The sequence parameter must be a sequence type, iterator, or other objects that support calendar editing. By calling the iterator returned by enumerate (), its next () method returns a tuple containing the count (starting from the start parameter and default value 0) and the corresponding value. You can use enumerate () to obtain an indexed sequence: (0, seq [0]), (1, seq [1]), (2, SEQ [2]),...
For example:
>>> For I, season in enumerate (['spring ', 'summer', 'fall', 'Winter ']):
... Print I, Season
0 spring
1 summer
2 fall
3 winter
This function is added in Version 2.3.
In version 2.6, the start parameter is added.
Eval (expression [, globals [, locals])
The expression parameter is a string. The optional globals parameter must be a dictionary, and the optional locals must be a mapping object ).
The expression parameter is parsed and evaluated as a python expression (evaluate). It uses the globals and locals dictionaries as global and local variables. The default value of the globals parameter is the current global variable. The default locals parameter is globals. If both parameters are omitted, Eval () is executed in the current context. Exceptions during execution are considered as syntactic errors. The following is an example of using Eval:
X = 1
Print eval ('x + 1 ')
The expression parameter can also be a code object (created through compile (). If the code object is compiled in 'exec 'mode (for example, Eval (compile ('3 + 4 ', '<string>', "EXEC"), the eval () function returns none.
Tip: exec () supports dynamic statement execution. execfile () is used to execute statements in the file. Globals () and locals () return the dictionary of global variables and local variables respectively. They can be passed in as parameters when eval and execfile are called.
Execfile (filename [, globals [, locals])
This function is similar to the exec statement, but it receives a file path as a parameter and executes the content in the file. It is different from the Import Statement: it does not use module management-it simply reads and executes the file content unconditionally without creating a new module.
The globals parameter of execfile () has the same meaning as the locals parameter and eval (), but the return value of the function is none.
File (filename [, mode [, bufsize])
File constructor. Its parameters are the same as those of the open () method. The open () method is described below.
To open a file, open () is usually used instead of file (). File () is more suitable for type testing (for example, isinstance (F, FLE )).
This function is added in this version 2.2.
Filter (function, iterable)
Apply functions to the elements in the programmable object to form a new list of elements with the result of true and return the results without changing the original list .). The iterable parameter can be a sequence, a container object supporting calendar editing, or an iterator object. If the parameter is of the string or tuple type, the returned result is of the original type. Otherwise, it always returns a list type. If the function is none, the identity function is used as a filter function to filter out non-true value elements)
Function equivalent:
Function is not none: [item for item in iterable if function (item)]
Function is none: [item for item in iterable if item]
Float ([x])
Converts a string or number to a floating point number. If the parameter is a string, it may contain symbols or decimal points. The string parameter can also be "+ Nan", "-nan" or "+ inf", "-Info". Otherwise, the parameter must be a common integer, a long integer, or a floating point number. The floating point number is directly returned. If no parameter is provided, the function returns 0.0.
Note:
If the parameter is a string, the function may return Nan (not a number), infinity (infinity), which depends on the low-level C language library. Float may receive "Nan" to indicate a non-number, INF and-inf to indicate a positive infinity and a negative infinity. For Nan, "+", "-" symbols are ignored. Float uses "Nan", "inf", and "-inf" to indicate Nan, positive infinity, and negative infinity.
Format (value [, format_spec])
Indicates a value in the specified format. Parsing the format depends on the value parameter. There is a set of standard format syntax for most Python built-in types.
Note:
Format (value, format_spec) only calls value. _ format _ (format_spec ).
This function is added in version 2.6.
Frozenset ([iterable])
Return a frozenset object, optionally with elements taken from iterable. The frozenset type is described in set types-set, frozenset.
For other containers see the built in dict, list, And tuple classes, and the collections module.
New in version 2.4.
Getattr (object, name [, default])
Obtains the value of a specified property of an object. The parameter name must be a string. If the name is the name of an attribute in the object, the value of this attribute will be returned. For example, getattr (X, "foobar") is equivalent to X. foobar. If the property name does not exist, the default parameter is returned. If the function name does not exist and the default parameter is not provided, attributeerror is triggered.
Globals ()
Returns the global variable Dictionary of the current module. (If globals () is called in a method or function, a global variable dictionary is returned for the module that defines the method or function, instead of the module where the function or method is called (the global variable dictionary ))
Hasattr (object, name)
Determines whether an object has a property with a specified name. (Hasattr calls getattr (object, name) to determine whether the attribute name exists based on whether an exception is thrown)
Hash (object)
Returns the hash value of an object. The hash value is an integer. It is used as the dictionary key for quick comparison during search. The hash value of a numeric object is the same as the value (even if they have different types, such:
Hash (1.0) = 1.0 # True
Hash (1.0) = hash (1) # True)
Help ([object])
Call system help. (This function can interact with the system ). If no parameters are provided, the interactive help system will be started on the parser console. If the parameter is a string, it will be queried as the name of the module, function, type, method, keyword, or file topic, and relevant help information will be displayed on the console; if the parameter is another type of object, the help information of the object is created (and displayed on the console ).
This function is added to the built-in naming domain through the site module.
This function is added in version 2.2.
Hex (X)
Returns the hexadecimal string representation of an integer. The result is a valid Python expression.
Only one unsigned literal value is returned before version 2.4.
ID (object)
The identifier of the returned object ). An identifier is an integer (or long integer) that is unique and remains unchanged during the object lifecycle. Two objects in a non-overlapping scope may have the same identifier. (In the current implementation, the identifier returns the address of the object in the memory .)
Input ([prompt])
Equivalent to eval (raw_input (prompt ))
Warning:
This function cannot ensure that the content entered by the user is valid. It expects a valid Python expression as the input. If a syntax error occurs in the input, syntaxerror is triggered. Other errors that occur during the value period also trigger corresponding exceptions. (On the other hand, this function is very useful when writing some quick scripts as advanced applications .)
If the Readline module has been loaded, the input () function uses this module to provide complex row editing and recording functions.
You should consider using the raw_input () function to obtain your general input.
INT ([x [, Radix])
Converts a string or value to a normal integer. If the parameter is a string, it may contain symbols and decimal points. The radix parameter indicates the conversion base (the default value is in decimal format). It can be a value in the range of [2, 36] or 0. If the value is 0, the system will parse the string content. If the radix parameter is provided but the X parameter is not a string, A typeerror is thrown. Otherwise, the X parameter must be a numerical value (Common integer, long integer, floating point number ). Convert floating point numbers by rounding off decimal places. If the result is out of the range indicated by a common integer, a long integer is returned. If no parameter is provided, the function returns 0.
For integer types, see numeric types-int, float, long, complex.
Isinstance (object, classinfo)
If the object is a type instance or an instance of the type derived class, true is returned. If the classinfo parameter is a type object and the parameter object is a class object or a derived class object, returns true. (Translator's note: for example, isinstance (A, type ())). If the parameter object is not a class instance or is not of a given type, the function returns false.
If the classinfo parameter is not a class, type, or tuples about the class or type (such as: (classa, classb), or other related tuples, A typeerror exception is triggered.
Added support for type information tuples in analyticdb 2.2.
Issubclass (class, classinfo)
If the class parameter is a subclass of the classinfo parameter, true is returned. A class is considered as its own subclass (Translator's note: issubclass (classa, classa) returns true ). The classinfo parameter can be a tuples of multiple class objects. In this case, each class in the tuples is checked.
ITER (O [, Sentinel])
Returns an iterator object. This function parses the first parameter based on the second parameter. If the second parameter is not provided, parameter o must be a set object and support the calendar editing function (_ ITER) or the series function (_ getitem _ () method is supported. The parameter is an integer and starts from 0). If the two functions are not supported, a typeerror exception is triggered. If the second parameter is provided, parameter o must be a callable object. In this case, create an iterator object and call the next () method of the iterator to call o without parameters each time. If the returned value is Sentinel, A stopiteration exception is triggered. Otherwise, this value is returned.
This function is added in version 2.2.
Len (s)
The length of the returned object. The parameter can be a sequence type (string, tuples, or list) or a ing type (such as a dictionary ).
List ([iterable])
List constructor. The iterable parameter is optional. It can be a sequence, a compiled container object, or an iterator object. This function creates an element value in the same order as the iterable parameter. If the parameter iterable is a list, a copy of the list will be created and returned, just like the statement iterable [:]. For example: List ('abc') Returns ['A', 'B', 'C'], list (1, 2, 3) Returns [1, 2, 3]. If no parameter is provided, an empty list is returned: [].
Locals ()
Update and return a dictionary that represents the current local variable.
Warning:
Do not modify the content in the dictionary returned by locals (). Changes may not affect the use of local variables by the parser.
Call locals () in the function body and return the free variable ). Modifying a free variable does not affect the parser's usage of the variable. Free variables cannot be returned in the class area.
Long ([x [, Radix])
Converts a string or number to a long integer. If the parameter is a string, it may contain symbols. The meaning of the parameter radix is the same as that in the INT () function. It is provided only when the parameter X is a string. Otherwise, X must be a common integer, a long integer, or a floating point number. If X is a long integer, its value is directly returned. The floating point number is converted into an integer by rounding off the decimal number. If no parameter is provided, the function returns 0l.
Map (function, iterable ,...)
Apply the function to each element in the iterable parameter and return the result as a list. If multiple iterable parameters exist, the function must receive multiple parameters. The elements of the same index in these iterable parameters are concurrently used as function parameters. If the number of elements in an iterable is less than that of others, the iterable is extended with none to make the number of elements consistent. If there are multiple iterable and the function is none, map () returns a list composed of tuples, each containing the corresponding index values in all iterable. The iterable parameter must be a sequence or any programmable object, and the function returns a list ).
Max (iterable [, argS...] [, key])
If only the iterable parameter is provided, the function returns the largest non-empty element in a programmable object (such as a string, tuples, or list. If multiple parameters are provided, the parameter with the largest returned value is used.
The optional parameter key is a single-parameter sorting function. If the key parameter is provided, it must be named, for example, max (a, B, c, key = fun) ---- I don't know what the function of the key parameter is?
Modified in version 2.5: an optional key parameter is added.
Min (iterable [, argS...] [, key])
If only the iterable parameter is provided, the function returns the smallest non-empty element in a programmable object (such as a string, tuples, or list. If multiple parameters are provided, the parameter with the minimum returned value is used.
The optional parameter key is a single-parameter sorting function. If the key parameter is provided, it must be named, for example, max (a, B, c, key = fun) ---- I don't know what the function of the key parameter is?
Next (iterator [, default])
Call the next () method of iterator to obtain the next element. If the default parameter is provided after the iterator is compiled, the default parameter is returned. Otherwise, a stopiteration exception is triggered.
This function is added in version 2.6.
Object ()
Obtain a new featureless object. Object is the base class of all classes. It provides methods that will be shared among all types of instances.
This function is added in version 2.2.
After Version 2.3, this function does not receive any parameters. Parameters can be received before, but these parameters are ignored.
Oct (X)
Converts an integer to an octal string. The result is a valid Python expression.
Before version 2.4, this function only returns the unsigned literal value.
Open (filename [, mode [, bufsize])
Open a file and return a file object. If the file cannot be opened, an ioerror occurs. Open () should be used instead of directly using the file type constructor to open the file.
The filename parameter indicates the path string of the file to be opened. The mode parameter indicates the mode in which the file is opened. The most common modes are 'R', which indicates reading a text file, 'W' indicates writing a text file, and 'A' indicates appending text content to the file. The default value of mode is 'R '. When operating a text file, '/N' may be converted to a specific platform-related representation.
When operating on a binary file, you only need to add 'B' to the mode value '. This improves the portability of the program. (Some operating systems do not distinguish between text files and binary files. These files are processed as documents. It is more appropriate to set the mode to binary .)
The optional parameter bufsize defines the file buffer size. 0 indicates no buffer (unbuffered); 1 indicates line buffered; Any other positive number indicates the buffer with this size; negative number indicates the system default buffer size, for tty devices, it is usually a row buffer, while for other files, it is often a full buffer. If the parameter is omitted, use the default value.
Ord (c)
Converts a string of 1 to an integer. For example, ord ('A') returns the Integer 97, ord (u '/u2020') returns 8224.
Pow (X, Y [, Z])
Returns the yth power of X. If the parameter Z is provided, returns the yth power of x and performs the modulo operation on Z (more efficient than POW (x, y) % Z ). You can also use X ** y to replace POW (x, y)
Print ([object,...] [, SEP = ''] [, end = 'n'] [, file = SYS. stdout])
The stream file is separated by the SEP parameter and ends with the end parameter. The SEP, end, and file parameters must appear in the form of keyword parameters, if provided.
All non-Keyword parameters are converted to strings and written to the stream. Separated by SEP, end is appended to the end. The SEP and end parameters are both strings or none, which means the default value is used. If no object exists, print () writes the end directly.
The file parameter must be an object that contains the write (string) method. If this method is not available or the object is none, use the default SYS. stdout.
Note: by default, the print method is unavailable because it is often considered a print statement. To use the print () method and disable the print Statement at the same time, add the following statement at the beginning of the module:
From _ future _ import print_function
This function is added in version 2.6.
Property ([fget [, fset [, fdel [, Doc])
...
Range ([start], stop [, step])
This is a pass and is used to create a list containing consecutive arithmetic values ). It is often used for a for loop. The parameter must be a normal integer. The default value of step is 1, and the default value of start is 0. When you call this function with all parameters, a list of common integers is returned: [start, start + step, start + 2 * step,...]. If step is a positive number, the last element in the list will be the maximum value, start + I * step, less than stop. If step is a negative number, the last element in the list will be the minimum value, start-I * step, greater than stop. The parameter step cannot be 0 (otherwise, a valueerror exception is triggered ).
>>> Range (10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> Range (1, 11)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> Range (0, 30, 5)
[0, 5, 10, 15, 20, 25]
>>> Range (0, 10, 3)
[0, 3, 6, 9]
>>> Range (0,-10,-1)
[0,-1,-2,-3,-4,-5,-6,-7,-8,-9]
>>> Range (0)
[]
>>> Range (1, 0)
[]
Raw_input ([prompt])
If the prompt parameter is provided, it will be written to the standard output (no line break at the end). The function then reads a row of data from the input, converts it to a string (removes the line break at the end), and returns the result. When EOF is read, an eoferror exception is triggered. The following is an example:
>>> S = raw_input ('--> ')
--> Monty Python's flying circus
>>> S
"Monty Python's flying circus"
Reduce (function, iterable [, initializer])
...
Reload (module)
Reload the previously imported (imported) module. The parameter is a module object, so the module must be successfully imported. Reload is very useful in this case: when the program is running, the module source code changes, so that the python parser can load the latest version of code without authorization. The return value of a function is a module object.
When reload (module) is executed:
The Python module code is re-compiled, module-level code is re-executed, and a new object letter is defined and bound to the module dictionary, the extension module's initialization function will not be called again.
Just like other objects in Python, some objects in the original module are recycled only when the reference value is 0.
The name in the module is updated to indicate any new or changed objects.
References to the original object are not rebound to the new object.
Repr (object)
Returns the string representation of an object. You can use this function to access operations. For many types, repr () tries to return a string, and the eval () method can use this string to generate an object; otherwise, it is enclosed by Angle brackets, strings containing Class names and other additional information (such as object names and addresses in memory) are returned. Class can control the output of its object by defining the _ repr _ () method.
Reversed (SEQ)
Returns an iterator object in reverse order. The seq parameter must be an object that contains the _ Reversed _ () method or support sequential operations (_ Len _ () and _ getitem __())
This function is added in version 2.4.
Round (X [, N])
Rounds the n + 1 decimal point of X to return a floating point number with N decimal places. The default value of parameter n is 0. The result is a floating point number. For example, the result of round (0.5) is 1.0.
Set ([iterable])
...
Setattr (object, name, value)
This method corresponds to getattr. Parameters are an object, string, and value respectively. A string may be an existing property name or a new property name. This function assigns the value to the property of the object. For example, setattr (x, 'fllbar', 123) is equivalent to X. foobar = 123.
Slice ([start], stop [, step])
...
Sorted (iterable [, CMP [, key [, reverse])
...
Staticmethod (function)
Returns a static method.
The static method does not explicitly receive the first parameter (as the type ). Use the following syntax to declare a static method:
Lass C:
@ Staticmethod
Def F (arg1, arg2 ,...):...
You can call static methods (such as C. F () in a class, or on an object (such as C (). F ()).
The static method in python is similar to the static method in Java or C ++. For more details, refer to: classmethod ()
This function is added in version 2.2.
STR ([object])
Obtains the string representation of an object. For string parameters, the function returns directly. The difference between repr () and STR () is that the string returned by STR () may not be evaluated by eval (), but only returns a printable string. If no parameter is provided, the Null String is returned.
Sum (iterable [, start])
Calculate the sum of elements in a programmable object and add them together with start. The default value of start is 0. The element of a programmable object is a number and cannot be a string. You can call ''. Join (sequence) to quickly and correctly connect a string sequence. Note: sum (range (N), m) is equivalent to reduce (operator. Add, range (N), m ). You can use math. fsum () to sum a high-precision floating point number ().
Super (type [, object-or-type])
Returns a proxy object of the parent or sibling type that can be called through the delegate method. Use it in the override method to access the virtual method in the parent class,
Tuple ([iterable])
Returns a tuples whose element values and sequence are the same as those in iterable. The parameter iterable can be a sequence or iterator object. If iterable itself is also a tuples, it will be returned by the original unblocking. For example, tuple ('abc') will return ('A', 'B', 'C'), tuple ([1, 2, 3]) will return (1, 2, 3 ). If no parameter is provided, the function returns an empty tuples.
Type (object)
Type of the returned object. The returned value is a type object. We recommend that you use isinstance () to check the object type. The type () function with three parameters is a type-class constructor, which is described in detail below.
Type (name, bases, dict)
Returns a class object. It is essentially a dynamic Class Definition Statement (you can dynamically create a new type ). The parameter name is used as the value of _ name _ as the name of the new type. The parameter bases is a tuples that indicate the parent class of the New Type and serves as the value of _ bases; the dict parameter is a dictionary that represents the definition of the class range Member and serves as the value of _ dict. For example, the following two statements create an object of the same type:
>>> Class X (object ):
... A = 1
...
>>> X = type ('x', (object,), dict (a = 1 ))
Unichr (I)
Returns the Unicode string of an integer. For example, unichar (97) returns the u'a' string '.
Unicode ([object [, encoding [, errors])
...
Vars ([object])
If no parameter is provided, a dictionary indicating the current local variable table is returned. If you enter a module object, class object, or class instance object (or any other object containing the _ dict _ attribute), a dictionary indicating the variable table of this object is returned.
Xrange ([start], stop [, step])
This function is very similar to range (), but it returns an xrange object instead of a list. This is an opaque sequence object that can generate values that are the same as the corresponding list but not save them at the same time (in memory ).
Compared with range, xrange consumes less memory.
Zip ([iterable,...])
The function returns a list of tuples. The element of the nth tuples is composed of the nth element of all parameter sequences. The length of the returned list is equal to the length of the sequence with the shortest length in the parameter. If multiple parameter sequences have the same length, if Zip () has only one parameter, the element length in the returned sequence is 1. If no parameter is provided, an empty list is returned.
>>> X = [1, 2, 3]
>>> Y = [4, 5, 6]
>>> Zipped = zip (x, y)
>>> Zipped
[(1, 4), (2, 5), (3, 6)]
>>> X2, y2 = zip (* zipped)
>>> X = x2, y = Y2
True
This function is added in version 2.0.
Before version 2.4, you must provide at least one parameter when calling zip (). Otherwise, a typeerror exception is triggered.
_ Import _ (name [, globals [, locals [, fromlist [, level])
This is an advanced function that is rarely used in normal programming.
This function is called when the import statement is used to load the module.
The _ import _ () function is rarely used unless the module name is obtained at runtime.