all列表
如果一个模块文件中有__all__ 变量,当使用from xxx import * 导入时,只能导入这个列表中的元素。
my_module2模块代码
# 定义多个功能,把某个功能添加到__all__ __all__ = ['testA'] def testA(): print('testA') def testB(): print('testB')
导入模块的文件代码
from my_module2 import * testA() # 因为testB函数没有添加到all列表,只有all列表里面的功能才能导入 # testB()

浙公网安备 33010602011771号