all在python中的使用
文件test.py
__all__= ['test', '']
def test_1():
print('test_1')
def test_2():
print('test_2')
class Test(object):
pass
在其他模块导入test的时候:
from test import *
# 在此地只能导入__all__里边的内容
文件test.py
__all__= ['test', '']
def test_1():
print('test_1')
def test_2():
print('test_2')
class Test(object):
pass
在其他模块导入test的时候:
from test import *
# 在此地只能导入__all__里边的内容
本文标题:2022-03-21
本文链接:https://www.haomeiwen.com/subject/fdktjrtx.html
网友评论