How to check the data type in python?
In the first step, we first need to know how to check the variable data type in python The type() function is used. The usage of the type function is as shown in the figure below:
The second step is to open the py file and enter
import numpy as npa1=123list=[1,2,3,4,5,6]array=np.array(list)print(type(a1))
to print out a1 The data type of the variable is as shown in the figure below:
After running the py file in the third step, you can see that the a1 variable is of type int, as shown in the figure below:
The fourth step is to enter
print(type(list))print(type(array))
Print out the types of list variables and array variables, as shown below:
The fifth step is to run the py file. You can see the list and array types respectively, as shown in the figure below:
Recommended: "Python Tutorial》
The above is the detailed content of How to check data type in python. For more information, please follow other related articles on the PHP Chinese website!