您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何确定Python变量的类型?

如何确定Python变量的类型?

PythonC / 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

不过,在Python 3.0中int和long之间的区别消失了。

python 2022/1/1 18:16:19 有439人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶