function format |
Using the example |
Describe |
int (x [, Base]) |
Int ("8") |
Can be converted to include string types and other numeric types, but will lose precision |
Float (x) |
Float (1) or float ("1") |
You can convert string and other numeric types, and the insufficient number of digits is 0, for example 1 becomes 1.0 |
Complex (real, imag) |
Complex ("1") or complex |
The first argument can be a string or a number, the second argument can only be a numeric type, and the second parameter is not 0 by default. |
STR (x) |
STR (1) |
Convert a number to a string |
REPR (x) |
Repr (Object) |
Returns the string format of an object |
eval (str) |
Eval ("12+23") |
Executes a string expression that returns the result of the calculation, as shown in the example 35 |
Tuple (SEQ) |
Tuple ((1,2,3,4)) |
A parameter can be a tuple, a list, or a dictionary, a collection of key components that return a dictionary when Wie |
List (s) |
List ((1,2,3,4)) |
Converts a sequence into a list of parameters that can be a tuple, dictionary, list, or dictionary, which returns a collection of key dictionaries |
Set (s) |
Set ([' B ', ' R ', ' U ', ' o ', ' n '), or set ("ASDFG") |
Transforms an iterative object into a mutable set, and repeats, returning the result that can be used to calculate the difference x-y, and the set × | Y, intersection X & y |
Frozenset (s) |
Frozenset ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) |
Transforms an iterative object into an immutable set, with parameters such as tuples, dictionaries, lists, and so on. |
Chr (x) |
Chr (0x30) |
Chr () returns a corresponding character by using an integer (that is, 0~255) in range (256) as a parameter. The return value is the ASCII character corresponding to the current integer. |
Ord (x) |
Ord (' a ') |
Returns the corresponding ASCII value, or the Unicode value |
Hex (x) |
Hex (12) |
Convert an integer to a hexadecimal string |
Oct (x) |
Oct (12) |
Convert an integer to an octal string |