溫馨提示×

python怎么查看變量的類型

小億
128
2023-08-20 02:12:48
欄目: 編程語言

在Python中,可以使用type()函數來查看變量的類型。示例如下:

x = 5
print(type(x))  # 輸出:<class 'int'>
y = 3.14
print(type(y))  # 輸出:<class 'float'>
z = "hello"
print(type(z))  # 輸出:<class 'str'>
is_valid = True
print(type(is_valid))  # 輸出:<class 'bool'>

在上面的示例中,通過type()函數將變量傳遞給它,它將返回變量的類型。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女