简体   繁体   中英

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"

print("HI")
import file2

which would then call "file2"

print("Hello")
import file1

How would I continue this loop without ending??

I would do it like this:

file.py

import file2

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

file2.py

def hello():
    print('Hello')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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