Python basic learning day 6: Python data types

built-in data types

In programming, data types are an important concept.

Variables can store different types of data, and different types can perform different operations.

Among these categories, Python has the following built-in data types by default:

insert image description here

get data type

You can get the data type of any object using the type() function:

example

Print the data type of variable x:

x = 10
print(type(x))

run instance

insert image description here

set data type

In Python, when you assign a value to a variable, the data type is set:

Please add a picture description

set a specific data type

If you wish to specify the data type, you can use the following constructors:

Please add a picture description

Guess you like

Origin blog.csdn.net/yxczsz/article/details/132604235