我制作了一个程序,最后要求您重新启动。
我import os
和用过os.execl(sys.executable, sys.executable, * sys.argv)
但什么也没发生,为什么?
这是代码:
restart = input("\nDo you want to restart the program? [y/n] > ")
if str(restart) == str("y"):
os.execl(sys.executable, sys.executable, * sys.argv) # Nothing hapens
else:
print("\nThe program will be closed...")
sys.exit(0)