Home  >  Article  >  Backend Development  >  python core data type analysis

python core data type analysis

高洛峰
高洛峰Original
2017-03-08 10:54:341489browse

Overview

python core data type analysis
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

##ItemOperationstr()The result is the same as printrepr ()The exact value of the object, but most use eval(repr(object)) == objectformat()format( value[, format_spec])

Convertible non-numeric value-->Numeric value

ProjectOperationint()Convert to integerfloat()Convert to floating point

Serialization

ProjectOperationlist()Convert string to listtuple()Convert string to tupleset()Convert string to setfrozenset()Convert the string into an immutable setdict()According to (key, value ) tuple list to create dictionary

characters and ASCII conversion

chr ord

Hexadecimal conversion

ProjectOperationbinConvert integers to binary stringsoctConvert integers to octal stringshexConvert integer to hexadecimal stringevalConvert 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn