Python 数据类型查看:使用 type() 函数
可以使用 type() 函数来查看数据类型。
例如:
a = 10
b = 3.14
c = 'Hello, World!'
d = [1, 2, 3]
e = {'name': 'Alice', 'age': 30}
print(type(a)) # <class 'int'>
print(type(b)) # <class 'float'>
print(type(c)) # <class 'str'>
print(type(d)) # <class 'list'>
print(type(e)) # <class 'dict'>
type() 函数返回一个对象的类型,可以用于所有的 Python 数据类型。
原文地址: https://www.cveoy.top/t/topic/nG2T 著作权归作者所有。请勿转载和采集!