Skip to content

Latest commit

 

History

History
33 lines (26 loc) · 557 Bytes

75.md

File metadata and controls

33 lines (26 loc) · 557 Bytes
rank vote view answer url
75 1615 2691500 16 url

如何查看 Python 变量的类型?


Python 不像 C/C++,不会出现你的问题

试一下:

>>> i = 123
>>> type(i)
<type 'int'>
>>> type(i) is int
True
>>> i = 123456789L
>>> type(i)
<type 'long'>
>>> type(i) is long
True
>>> i = 123.456
>>> type(i)
<type 'float'>
>>> type(i) is float
True

在 Python3.0中 int 和 long 已经不再进行区分了.