在
Python 2.x中,在长整数后面有一个L后缀.由于Python 3将所有整数视为长整数,因此已将其删除.从
What’s New In Python 3.0开始:
The repr() of a long integer doesn’t include the trailing L anymore, so code that unconditionally strips that character will chop off the last digit instead. (Use str() instead.)
从这里我得到repr()不会显示L后缀,但str()将具有L后缀.但在Python 3.3.3中,没有一个显示L后缀.
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> repr(2 ** 64)
'18446744073709551616'
>>> str(2 ** 64)
'18446744073709551616'
根据文档,str()的输出不应该是18446744073709551616L吗?我在What’s New In Python 3.1,What’s New In Python 3.2和What’s New In Python 3.3中找不到任何说明L后缀从str()中删除的内容. 3.2说:
The str() of a float or complex number is now the same as its repr().
但它没有说整数.
从str()中删除了哪个版本的Python L后缀?还是我错过了一些明显的东西?