__all__ = ['test1'] def test1(): print("-----test1-----") def test2(): print("-----test2-----")
在模塊的一開始定義 __all__ 變量,import該模塊后,只能找到 __all__中存在的變量或者函數,其他的不能調用
__all__ = ['test1'] def test1(): print("-----test1-----") def test2(): print("-----test2-----")
在模塊的一開始定義 __all__ 變量,import該模塊后,只能找到 __all__中存在的變量或者函數,其他的不能調用
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。