几年后更新:Python
3.6现在支持PEP515,因此您可以使用_来提高浮点数和整数文字的可读性。
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> 1_100011000>>>
作为历史参考,您可以查看严格定义python2.7,python3.5 …的词法分析。
对于python3.6.0a2及更早版本,您应该收到类似于以下内容的错误消息:
Python 3.6.0a2 (v3.6.0a2:378893423552, Jun 13 2016, 14:44:21) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1_000 File "<stdin>", line 1 1_000 ^SyntaxError: invalid syntax>>> amount = 10_000_000.0 File "<stdin>", line 1 amount = 10_000_000.0^SyntaxError: invalid syntax



