一.说明
因为python语言的不断变化,所以下面总结的内容在python的某一个版本中可能不适用,具体以python官网文档为准。
二._xxx单下划线开头
官方文档说明:
_single_leading_underscore:
weak "internal use" indicator. E.g. from M import * does not import objects whose name starts with an underscore.
(1)翻译:这是一种提示,提示程序员这是供“内部使用”的,例如:不能通过“from module import *”导入。
(2)对于变量:无影响。
(3)对于函数:该函数不能通过“from module import *”导入,但是可以通过常规的的方式导入。
示例代码见参考资料。
三.xxx_单下划线结尾
官方文档说明:
single_trailing_underscore_: used by convention to avoid conflicts with Python keyword, e.g.
Tkinter.Toplevel(master, class_='ClassName')
(1)翻译:为了避免和Python关键字冲突。
(2)对于变量:为了避免和Python关