Python模块化脚本包括另一个脚本

2024-06-26 02:37:13 发布

您现在位置:Python中文网/ 问答频道 /正文

需要做一个容器应用程序,将运行不同的模块配置。 i、 容器应用程序是A,在A里面我可以加上B,这是另一个可以计算的脚本,否则我可以加上C,这是一个读取值的脚本。你知道吗

进口有可能吗?最好的做法是什么?你知道吗

A = run a while cicle
B = run some functions
c = run another set of functions

A.py公司

a=0
while 1:
    import B
    import C

B.py公司

def pippo():
    print a=a+1
if __name__ == "__main__":
    pippo()

Tags: 模块runpyimport脚本应用程序another公司