选择频道搜索
要获取数据类型,可以使用Python内置的type()函数。例如:
x = 5print(type(x)) # 输出:<class 'int'>
另外,还可以使用isinstance()函数来检查某个变量是否属于特定的数据类型。例如:
x = "Hello"print(isinstance(x, str)) # 输出:True