python如何检查一个变量是否为特定类型

type()==什么呀
对于检查一个变量是否为特定类型
type(variable)是吗?

有两种办法:
第一种:

t = [1,2,3]
data_type = type(t)
print("The data type is: {}".format(data_type))

第二种:

t = [1,2,3]
is_list = isinstance(t, list)
print("The data type is list: {}".format(is_list))