简体   繁体   English

你如何像循环一样重新运行两个 python 脚本

[英]How do you rerun two python scripts like in a loop

For example, I want to run this code in a python file titled "file1"例如,我想在名为“file1”的 python 文件中运行此代码

print("HI")
import file2

which would then call "file2"然后将调用“file2”

print("Hello")
import file1

How would I continue this loop without ending??我将如何继续这个循环而不结束?

I would do it like this:我会这样做:

file.py文件.py

import file2

while True:
    print('Hi')
    file2.hello()

file2.py文件2.py

def hello():
    print('Hello')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM