私信  •  关注

gregjor

gregjor 最近创建的主题
gregjor 最近回复了
17 年前
回复了 gregjor 创建的主题 » 在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之间的区别消失了。