共計 235 個字符,預計需要花費 1 分鐘才能閱讀完成。
在 Python 中,可以使用 type() 函數來查看變量的類型。例如:
x = 5
print(type(x)) # <class 'int'>
y = 3.14
print(type(y)) # <class 'float'>
z = "Hello, world!"
print(type(z)) # <class 'str'>
上述代碼中,通過使用 type() 函數,分別打印了整數變量 x,浮點數變量 y 和字符串變量 z 的類型。
丸趣 TV 網 – 提供最優質的資源集合!
正文完