Python 入門到精通 — 數據類型
內容
數據類型樹
如何使用 Python 的數據類型 ✈️
"""
data types
"""
# int / float
x = 1
y = 1.1
print(type(x))
print(type(y))
# bool
a = True
b = False
print(type(a))
print(type(b))
# str
z = "Hello"
print(type(z))
# list
c = [1, 2, 3]
print(type(c))
# tuple
d = (1, 2, 3)
print(type(d))
e = (1, ..., 9)
print(type(e))
# set
f = {1, 2, 3}
print(type(f))
# dict
g = {"car": "red", "wheel": 4}
print(type(g))
結果
<class 'int'>
<class 'float'>
<class 'bool'>
<class 'bool'>
<class 'str'>
<class 'list'>
<class 'tuple'>
<class 'tuple'>
<class 'set'>
<class 'dict'>