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, first-in-first-out pipes (fifos) , Socket file (socket)
Type conversion
Non-character -->Character
Project |
Operation |
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]) |
Non-numeric value that can be converted-->Numeric value
Project |
Operation |
int() |
Convert to integer |
float() |
Convert to floating point |
Serialization
Project |
Operation |
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 a dictionary |
Character and ASCII conversion
chr() ord()
Copy after login
Hexadecimal conversion
Item |
Operation |
##bin | Convert the integer Convert to binary string |
oct | Convert integer to octal string |
hex | Convert an integer to a hexadecimal string |
eval | to a numerical value |
The above is the detailed content of Introduction to python core data types. For more information, please follow other related articles on the PHP Chinese website!