Home > Backend Development > Python Tutorial > Introduction to python core data types

Introduction to python core data types

高洛峰
Release: 2017-03-09 09:52:21
Original
2343 people have browsed it

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()
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template