在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的類型。