美文网首页
2022-03-21

2022-03-21

作者: 风声细碎 | 来源:发表于2022-03-21 15:43 被阅读0次

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__里边的内容

相关文章

网友评论

      本文标题:2022-03-21

      本文链接:https://www.haomeiwen.com/subject/fdktjrtx.html