Home  >  Article  >  Backend Development  >  How to check data type in python

How to check data type in python

藏色散人
藏色散人Original
2019-09-30 13:29:139676browse

How to check data type in python

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:

How to check data type in python

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:

How to check data type in python

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:

How to check data type in python

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:

How to check data type in python

The fifth step is to run the py file. You can see the list and array types respectively, as shown in the figure below:

How to check data type in python

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!

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