전체 스크립트를 다시 실행하지 않고 main
을 다시 실행하려면 어떻게해야합니까?Python 3.5에서 스크립트 다시 실행
import sys #importing module that is used to exit the script
def main():
#doing stuff
main()
#Re-run the script - looking for a cleaner way to do this!
def restart():
restart = input("Press any key + Enter to start again, or x + Enter to exit.")
if(restart != "x"):
exec(open("./calc.py").read())
# not sure how to run main() again without calling out the script name again?
else:
print ("Exiting!")
sys.exit ((main))
restart()
#End of Program
그냥'main()'을 다시 호출 하시겠습니까? 근데 왜 너 한테'간부 '하는거야? – jonrsharpe
OP의 원래 게시물은 프로그래밍/파이썬을 시작하고 있으며 = 그들이 배우고 있다고 말했기 때문에) – davedwards