Overview
Numbers: int, long, float, complex, bool
Characters: str, unicode
List: list
Dictionary: dict
Tuple: tuple
File: file
Other types: set, frozenset, class type, None
Other file tools: pipes, fifos, sockets Word file (socket)
Type conversion
Non-character -->Character
str() | The result is the same as print |
repr () | The exact value of the object, but most use eval(repr(object)) == object |
format() | format( value[, format_spec]) |
Convertible non-numeric value-->Numeric value
int() | Convert to integer |
float() | Convert to floating point |
Serialization
list() | Convert string to list |
tuple() | Convert string to tuple |
set() | Convert string to set |
frozenset() | Convert the string into an immutable set |
dict() | According to (key, value ) tuple list to create dictionary |
characters and ASCII conversion
chr ord
Hexadecimal conversion
bin | Convert integers to binary strings |
oct | Convert integers to octal strings |
hex | Convert integer to hexadecimal string |
eval | Convert to numerical value |
The above is the detailed content of python core data type analysis. For more information, please follow other related articles on the PHP Chinese website!