python 变量类型
There are two inbuilt methods available in python to determine the variable's type.
在python中有两种可用的内置方法来确定变量的类型。
1)type()方法 (1) type() method)
If a single argument is passed to type(), it returns type of the given object.
如果将单个参数传递给type() ,则返回给定对象的类型。
Syntax:
句法:
type(object)
Example:
例:
>>> test_string = "yes"
>>> test_number = 1
>>> print(type(test_string))
<class 'str'>
>>> print(type(test_number))
<class 'int'>