Introduction to python core data types
Mar 09, 2017 am 09:52 AMOverview
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
1 |
|
Hexadecimal conversion
##binConvert the integer Convert to binary stringoctConvert integer to octal stringhex Convert an integer to a hexadecimal string eval to a numerical valueItem | 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!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What are the advantages and disadvantages of templating?

Google AI announces Gemini 1.5 Pro and Gemma 2 for developers

For only $250, Hugging Face's technical director teaches you how to fine-tune Llama 3 step by step

Share several .NET open source AI and LLM related project frameworks

A complete guide to golang function debugging and analysis
