# Python built-in functions Daquan (category)

Source: Internet
Author: User
Tags bbcode iterable

python built-in functions

Recently, I've been looking at Python's document, and I'm going to focus on the basics. Python's keyword, build-in Function, build-in Constants, build-in Types, build-in Exception these four aspects, in fact, when looking at the whole "the Python Standard Library" chapter is very good, which describes a lot of good topics. First of all, build-in function list, beginner's understanding, classification may be inaccurate, communicate together.

first, the mathematical operation class
 ABS (x) Seek absolute value1, the parameters can be integral type, can also be plural2, if the parameter is a complex number, then return the modulus of the complex Complex ([real[, Imag]]) Create a complex number Divmod (A, B) Separate fetch and remainderNote: integral, floating-point types can be float ([x]) Converts a string or number to a float. If no parameter is returned 0.0 int ([x[, Base]]) Converts a character to an int type, and base represents the binary Long ([x[, Base]]) Converts a character to a long type Pow (x, y[, z]) Returns the Y power of X Range ([start], stop[, step]) Produces a sequence that starts with 0 by default Round (x[, N]) Rounded Sum (iterable[, start]) Sum the Set Oct (x) Convert a number to 8 binary Hex (x) Converts an integer x to a 16-binary string Chr (i) Returns the ASCII character corresponding to the integer i Bin (x) Converts an integer x to a binary string BOOL ([x]) Convert X to Boolean type

second, the collection class operation
 Basestring () Super class for STR and Unicodecannot be called directly and can be used as isinstance judgment Format (value [, Format_spec]) Formatting the output stringFormatted parameter order starting from 0, such as "I am {0},i like {1}" UNICHR (i) Returns the Unicode of the given int type Enumerate (sequence [, start = 0]) Returns an enumerable object that returns a tuple for the next () method of the object. ITER (o[, Sentinel]) Generates an iterator for an object, and the second parameter represents a delimiter Max (iterable[, args ...] [Key]) Returns the maximum value in the collection Min (iterable[, args ...] [Key]) Returns the minimum value in the collection Dict ([ARG]) Create a data dictionary List ([iterable]) To convert a collection class to another collection class Set () Set Object instantiation Frozenset ([iterable]) Produces an immutable set STR ([object]) Convert to String type Sorted (iterable[, cmp[, key[, reverse]]) Team Collection Sort Tuple ([iterable]) Generate a tuple type Xrange ([start], stop[, step]) The xrange () function is similar to range (), but xrnage () does not create a list, but instead returns a Xrange object that behaves like a list, but calculates the list value only when it is needed, which saves us memory when the list is large.

third, logical judgment
 All (iterable) 1, the elements in the collection are true when they are true2, special, if the empty string returned to True Any (iterable) 1, the elements in the collection have a true time for the true2, special, if the empty string returned to False CMP (x, y) If x < Y, returns a negative number; x = = y, returns 0;x > y, returns a positive number

Iv. Reflection
 Callable (object) Checks whether object objects can be called1, the class is can be called2. Instances cannot be invoked unless the __call__ method is declared in the class Classmethod () 1, annotations, to illustrate this way is a class method2. Class methods can be called by the class or by instance3. The class method is similar to the static method in Java4. The self parameter is not required in a class method compile (source, filename, mode[, flags[, Dont_inherit]) compile source as code or AST object. The code object can be evaluated by EXEC statement execution or eval (). 2, parameter filename: code file name, and pass some recognizable values if the code is not read from the file. 3, parameter model: Specifies the kind of compiled code. can be specified as ' exec ', ' eval ', ' single '. Dir ([Object]) 1, without parameters, returns the list of variables, methods, and definitions in the current scope;2, with parameters, returns the properties of the parameter, the method list.3. If the parameter contains method __dir__ (), the method will be called. When the argument is an instance.4. If the parameter does not contain __dir__ (), the method will collect the parameter information to the maximum Delattr (object, name) Delete an object named Name property eval (expression [, globals [, locals]]) Evaluates the value of an expression ExecFile (filename [, globals [, locals]]) The usage is similar to exec (), the difference is that the execfile parameter filename is the file name, and the exec parameter is a string. Filter (function, iterable) Constructs a sequence that is equivalent to [item for item ' in Iterable if function (item)]1, Parameter function: Return a value of TRUE or false functions, can be none2. Parameter iterable: A sequence or an iterative object GetAttr (object, name [, Defalut]) Gets the properties of a class Globals () Returns a dictionary that describes the current global symbol table Hasattr (object, name) Determines whether the object contains an attribute named name Hash (object) Returns the hash value of object if object is a hash table type ID (object) Returns the unique identity of an object Isinstance (object, ClassInfo) Determine if object is an instance of class Issubclass (class, ClassInfo) Determine if it is a subclass Len (s) Return collection length Locals () Returns the current list of variables Map (function, iterable, ...) Iterate through each element to perform a function operation Memoryview (obj) Returns an object of a memory image type Next (iterator[, default]) Similar to Iterator.next () Object () Base class Property ([Fget[, fset[, fdel[, Doc]]) The wrapper class for property access, which can be set to access the setter and getter via C.x=value, etc. Reduce (function, iterable[, initializer]) The merge operation, which starts with the first two parameters, and then the first two results are processed with the third merge, and so on Reload (module) Reload Module SetAttr (object, name, value) Setting property values Repr (object) Changing an object to a printable format Slice () Staticmethod Declares a static method, which is an annotation Super (type[, Object-or-type]) Referencing a parent class Type (object) Returns the type of the object VARs ([object]) Returns the variable of the object, if no argument is similar to the Dict () method ByteArray ([Source [, encoding [, errors]]) Returns a byte array1, if source is an integer, returns an initialized array of length source;2. If source is a string, the string is converted to a sequence of bytes according to the specified encoding;3. If source is an iterative type, the element must be an integer in [0, 255];4. If source is an object that is consistent with the buffer interface, this object can also be used to initialize the ByteArray. Zip ([iterable, ...]) is not understand, just see the matrix of the changing aspects

v. IO operation
 File (filename [, mode [, BufSize]]) A constructor for the file type that opens a file that is created if the file does not exist and mode is write or append. Adding ' B ' to the mode parameter will manipulate the file in binary form. Adding ' + ' to the mode parameter will allow simultaneous read and write operations to the file1. Parameter filename: Name of the file.2, Parameter mode: ' R ' (read), ' W ' (write), ' a ' (append).3, parameter bufsize: If 0 is not buffered, if 1 is a row buffer, if it is a number greater than 1 indicates the size of the buffer. Input ([prompt]) Get user inputIt is recommended to use raw_input because the function will not capture the user's error input Open (name[, mode[, Buffering]) Open FileWhat is the difference from file? Recommended use of Open Print Print function Raw_input ([prompt]) Set input, input is handled as String

Vi. Other

Help ()--Information

Vii. PostScript

Built-in functions, generally because the use of frequency is more frequent or meta-operation, so through the form of built-in functions provided, through the Python built-in function classification analysis can be seen: basic data operations are basically some mathematical operations (except subtraction), logical operations, set operations, basic IO operations , and then it is the reflection of the language itself, but also the operation of the string, is also more commonly used, especially the need to pay attention to the reflection operation.

Python built-in functions Daquan (category)

Related Keywords:
Related Article

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.