文本来自:
https://blog.csdn.net/wuxuanecios/article/details/89673400
Python3本身支持中文命名类/方法/变量
任何额外的库和工具都不需要, 不需要, 不需要! 重要的话三遍. Python3本身就可以正确运行下面的代码:
补一句, 不光是Python3支持中文命名哦, 以后一个一个语言讲过来, 九成九你用的编程语言也支持.
下面是一个Python实用小程序的代码片段:
Python3为什么支持非ASCII码命名标识符
Python2并不支持非ASCII码标识符. 于2008年12月发布的Python3开始支持. 2008年! 也就是十多年前, 现在还不知道的话, 你就OUT大了.
创建于2007年5月的Python增强提案PEP 3131 – Supporting Non-ASCII Identifiers阐述了支持非ASCII码命名标识符的缘由. Rationale (依据) 一节开篇明义, 指出很多Python开发者并不熟悉英语, 更希望用母语对类/方法进行命名, 而不是用经常有误的英文翻译. 对使用同样母语的开发者来说, 用母语命名的标识符可以提高代码清晰度和可维护性.
Python code is written by many people in the world who are not familiar with the English language, or even well-acquainted with the Latin writing system. Such developers often desire to define classes and functions with names in their native languages, rather than having to come up with an (often incorrect) English translation of the concept they want to name. By using identifiers in their native language, code clarity and maintainability of the code among speakers of that language improves.