[英]Restart the whole script in python
Is there a way to restart script in python.有没有办法重新启动 python 中的脚本。 This is the way I tried but it just gets stuck after some time.
这是我尝试过的方式,但它只是在一段时间后卡住了。 And when i use the
os.excel
and os.excev
it doesn't work it just returns a error当我使用
os.excel
和os.excev
它不起作用它只是返回一个错误
os.system("start cmd /c python" + __file__)
So, What I need to do is make this function restart the script所以,我需要做的是让这个 function 重新启动脚本
def main():
os.system("start cmd /c python" + __file__)
If anybody knows the answer, please help如果有人知道答案,请帮忙
Use a loop like this使用这样的循环
while True:
#Your code here
continue
The continue will start the code from while True:
continue 将从
while True:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.