我一直在编写一个Python程序,但是Python的语法对我来说还是比较新的。例如,如果我有两个包含以下内容的Python文件,那么执行函数的正确方法是什么
main.py-这是正在执行的文件
#!/usr/bin/env python
#threading array
threads = []
import threading
import anotherFile as af
afCheck = af.init() #return true or false
if afCheck == True:
threads.append(threading.Thread(target=af.listener))
try:
for thread in threads:
thread.start()
except (KeyboardInterrupt, SystemExit):
print("closing up shop");
for thread in threads:
thread.cancel()
sys.exit()
我本来打算为anotherFile.py编写一些伪代码,但这似乎无关紧要。我已经能够测试到我看到它没有执行侦听器的程度,并且我不确定调用它的正确方法
也许我只需要在anotherFile.py中插入侦听器,但是为了简单起见,最好将它们都放在一个地方,因为这将有多个导入
目前没有回答
相关问题 更多 >
编程相关推荐