Python 的四种下划线
_var: 一种约定风格(PEP 8),表示私有化属性或方法或类,不是Python强制规定
from modules import * 导入时不会导入_开头的方法
__var:双前置下划线,避免多继承时的属性命名冲突,无法在外部直接访问(名字重整为`_类名__属性名`)
__var__:双前后下划线,用户名字空间的魔法对象或属性。例如:__init__
var_:单后置下划线,用于避免与Python关键词的冲突
参考:
- https://blog.csdn.net/weixin_38382105/article/details/79939501?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2~default~CTRLIST~default-1.no_search_link&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2~default~CTRLIST~default-1.no_search_link&utm_relevant_index=1
- https://blog.csdn.net/colourful_sky/article/details/81262449?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2~default~CTRLIST~default-1.no_search_link&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2~default~CTRLIST~default-1.no_search_link&utm_relevant_index=1
- https://blog.csdn.net/weixin_38753213/article/details/105501913?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~default-1.no_search_link&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~default-1.no_search_link&utm_relevant_index=2
本文来自博客园,作者:chuangzhou,转载请注明原文链接:https://www.cnblogs.com/czzz/p/15788557.html