Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - It's too complete! Summary of Common Built-in Functions in Python3
It's too complete! Summary of Common Built-in Functions in Python3
Mathematical correlation

Abs(a): find the absolute value. abs(- 1)

Max(list): Find the maximum value of list. Max ()

Min(list): Find the minimum value of list. Minimum value ()

Sum(list): Find the sum of list elements. sum()& gt; & gt& gt VI

Sorted(list): Sorts and returns the sorted list.

Len(list): list length, len ()

Divmod(a, b): Get quotient and remainder. divmod(5,2)>& gt& gt(2, 1)

Pow(a, b): Get the power number. Pow (2,3) >>> VIII

Round(a, b): Get the decimal of the specified number of digits. A stands for floating point number, and b stands for the number of digits to be reserved. round(3. 14 15926,2)>& gt& gt3. 14

Range (a

Type transformation

Int(str): Convert to int type. int(' 1 ')& gt; & gt& gt 1

Float(int/str): Converts an int or character type to a floating-point type. float(' 1 ')& gt; & gt& gt 1.0

Str(int): Convert to character type. str( 1)>& gt& gt' 1'

Bool(int): Convert to Boolean type. str(0)>; & gt& gtFalse string (none) >>& gt wrong

Bytes(str, code): receives a string and the format to be encoded, and returns a byte stream type. Bytes ('abc',' UTF-8') > & gt& gtB'abc' bytes (U' reptile',' UTF-8') > > & gtb'xe7x88xacxe8x99xab '

List(iterable): convert to list. list(( 1,2,3))& gt; & gt& gt

ITER: Returns an iterable object. ITER()& gt; The list_iterator object at>> & lt0x000000003813b00 >;

Dict(iterable): Convert to dict. dict([('a ', 1),(' b ',2),(' c ',3)])& gt; & gt& gt{'a': 1,' b':2,' c':3}

Enumerate(iterable): Returns an enumerated object.

Iterable: Convert to a tuple. tuple()& gt; & gt& gt( 1,2,3)

Set(iterable): convert to set. set()& gt; & gt& gt{ 1, 2,3,4,5} set ({1:'a', 2:'b', 3:' c'}) > & gt& gt{ 1,2,3}

Hex(int): converted to 16. Hexadecimal (1024) > > >' 0x400'

Oct(int): Convert to octal. oct( 1024)>& gt& gt' 0o2000 '

Bin(int): Convert to binary. bin( 1024)>& gt& gt0b 1000000000 '

Chr(int): Convert numbers into corresponding ASCI code characters. Chr(65)>& gt& gt one

Ord(str): Convert ASCI characters into corresponding numbers. order(‘A’)>& gt& gt65

Related operation

Eval**** * * (): Execute an expression or string as an operation. eval(' 1+ 1 ')& gt; & gt& gt2

Exec (): Execute python statement. exec(' print(" Python ")')& gt; > > computer programming language

Filter(func, iterable): filter the eligible elements by judging the function fun. Filter (λ x: x >; 3,)>& gt& gt& lt filters the object at 0x000000003813828 >.

Map (func, * iterated): Use func for each iterative object. map(λa,b: a+b,,)& gt& gt& gt[6,8, 10]

Zip (* iterate): Combines iterative groups. Returns a zip object. list(zip(,)& gt& gt& gt[( 1, 4), (2, 5), (3, 6)]

Type (): Returns the type of the object.

Id (): Returns the unique identification value of the object.

Hash(object): Returns the hash value of an object, and objects with the same value have the same hash value. Hash ('python') >; & gt& gt707080835926 1009780

Help (): Call the built-in help system.

Isinstance (): Determines whether the object is an instance of this class.

Issubclass (): Determines whether a class is a subclass of another class.

Globals (): Returns the dictionary of the current global variable.

Next(iterator[, default]): receives an iterator and returns the value in the iterator. If default is set, the contents of the default will be output after the elements traversed by the iterator.

Reversed(sequence): An iterator that generates a reverse sequence. Inversion ('ABC ')& gt;; & gt& gt['c ',' b ',' a']