Python提供了内置函数type()来查询一个变量的类型。下面是使用type()函数查询变量类型的示例代码: # 定义一个整数变量num=10print(type(num))# 输出:<class 'int'># 定义一个字符串变量name="Alice"print(type(name))# 输出:<class 'str'># 定义一个列表变量my_list=[1,2,3]print(type(my_list))# ...
print("{0}是{1}".format(money,getType(money))) #判断变量是否为列表 students=['studentA'] print("{0}是{1}".format(students,getType(students))) #判断变量是否为元组 students=('studentA','studentB') print("{0}是{1}".format(students,getType(students))) #判断变量是否为字典 dictory={"...