Home  >  Article  >  Backend Development  >  Introduction to python core data types

Introduction to python core data types

高洛峰
高洛峰Original
2017-03-09 09:52:212305browse

Overview

Introduction to python core data types

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()

Hexadecimal conversion

##binConvert the integer Convert to binary stringoctConvert integer to octal stringhex Convert an integer to a hexadecimal string eval to a numerical value
Item Operation

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!

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