Python 獲取資料型別
獲取資料型別
您可以使用 type()
函式獲取任何物件的資料型別
以下是 Python 中所有內建資料型別
示例
print(type("Hello"))
print(type(3))
print(type(3.14))
print(type(1j))
print(type(["apple", "banana", "cherry"]))
print(type(("apple", "banana", "cherry")))
print(type(range(6)))
print(type({"name" : "John", "age" : 36}))
print(type({"apple", "banana", "cherry"}))
print(type(frozenset({"apple", "banana", "cherry"})))
print(type(True))
print(type(b"Hello"))
print(type(bytearray(5)))
print(type(memoryview(bytes(5))))
自己動手試一試 »