Python built-in functions

Source: Internet
Author: User

I. What is a built-in function

A built-in function is a function that Python gives you, using directly. Up to Python version 3.6.2python provides a total of 68 built-in functions, which Python provides directly to us.

Scope-dependent

Locals () returns the name in the current scope

Globals () returns the name in the global scope

Iterator Related:

Range () to generate data

Next () iterator is executed down once, and the __next__ () is actually used internally to return the next item of the iterator

ITER () Gets an iterator that internally actually uses the __iter__ method to get the iterator

Execution of String type code

Eval () executes the string code and returns the final result

EXEC () Executes the string type code

Compile () compiles code of string type, which can be evaluated by EXEC statement execution or eval ()

Input/output related

Input () Gets the content entered by the user

Print () output

Memory-related

Hashes () Gets the hash value of the object

ID () Gets the memory address of the object

File Operation related

Open () Opens a file, creates a file handle

Module-related

__import__ () for dynamically loading classes and functions

Help

The Help () function is used to view a detailed description of the function or module's purpose

Call the relevant

Callable () is used to check if an object is callable, and if it is returned true,object it is possible for the call to fail, but if it returns false, the call will not succeed

Dir () View the object's built-in properties, methods, and access to the __DIR__ () method in the object

Digital correlation

BOOL () Converts the given data to a bool value, and returns False if no value is given

Int () Converts the given data to an int value, and returns 0 if no value is given.

Float () Converts the given data into a float value, which is a decimal

Complex () creates a complex number, the first argument is the real part, the second argument is a virtual part, or the first parameter describes the complex number directly with a string

Binary conversion

Bin () converts the given parameters into binary

OTC () converts the given parameters into eight-binary

Hex () Converts the given parameter to hexadecimal

Mathematical operations

ABS () return absolute value

Divmode () return quotient and remainder

Round () rounding

The POW (A, B) asks for the power of a, and if there are three parameters, the third number is taken after the second power.

SUM () sum

Min () to find the minimum value

Max () to find the maximum value

and data structure related

Lists and tuples

List () converts an iterative object to a table

Tuple () Converts an iterative object to a Narimoto group

Reversed () will reverse the sequence, returning an iterator that reverses the sequence

Slices of the slice () list

 String-related

STR () converts data into a string

Format () related to specific data, used to calculate various decimals, actuarial, etc.

Bytes () Converts a string to a bytes type

ByteArray () Returns a new byte array in which the elements are mutable, and the range of values for each element is [0,256]

Memoryview () view bytes in memory

Ord () input characters find the location with character encoding

Chr () Enter position number to find the corresponding character

ASCII () is the ASCII code that returns the value, not the return \u ...

Repr () returns the string form of an object

 Data collection

Dict () Create a dictionary

Set () creates a collection

Frozenset () Creates a frozen collection that cannot be added and removed by a frozen collection

Other related

Len () returns the number of elements in an object

Sorted () Can iterate over objects for sorting operations

Enumerate () Gets the enumeration object for the collection

All () iterate pairs all of the objects are true, and the result is true

Any () One of the iterated objects is true, and the result is true

The zip () function is used to wrap an object in an object as an argument, package the corresponding element into a tuple, and then return a list of these elements, returning the same length as the shortest object if the number of elements in each iterator is inconsistent

Filter () Filtering

Map () maps the specified sequence according to the provided function (LAMDA)

Python built-in functions

Related Article

Contact Us

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.