Python __all__变量用法
以前面章节中创建的 demo.py 模块文件和 test.py 文件为例(它们位于同一目录),各自包含的内容如下所示:
#demo.py
def say():
print("人生苦短,我学Python!")
def CLanguage():
print("C语言中文网:http://c.biancheng网站站点" rel="nofollow" />
人生苦短,我学Python!
C语言中文网:http://c.biancheng网站站点" rel="nofollow" />人生苦短,我学Python!
C语言中文网:http://c.biancheng网站站点" rel="nofollow" />def say():
print("人生苦短,我学Python!")
def CLanguage():
print("C语言中文网:http://c.biancheng网站站点" rel="nofollow" />
人生苦短,我学Python!
C语言中文网:http://c.biancheng网站站点" rel="nofollow" />#demo.py
def say():
print("人生苦短,我学Python!")
def CLanguage():
print("C语言中文网:http://c.biancheng网站站点" rel="nofollow" />
人生苦短,我学Python!
C语言中文网:http://c.biancheng网站站点" rel="nofollow" />from demo import say
from demo import CLanguage
from demo import disPython
say()
CLanguage()
disPython()
运行 test.py,输出结果为:
人生苦短,我学Python!
C语言中文网:http://c.biancheng网站站点" rel="nofollow" />