I was happy that it went well, so it's a memo ...
There was a scene in the python code where I wanted to restart myself with new arguments. I thought about handing it over to another shell or Python, but the code seemed to be confusing, so ...
I referred to the following article. https://stackoverflow.com/questions/31447442/difference-between-os-execl-and-os-execv-in-python
import os
import time
import sys
gets=int(sys.argv[1])
cnt=0
while cnt<5:
print(cnt+gets)
cnt+=1
time.sleep(1)
os.execl(sys.executable, 'python', __file__,str(cnt+gets))
It is important that the second argument is naming.
1st argument → python executable file
Second argument → task name
Third argument → Python file to execute
(The rest is an argument ...)
I was really worried.
Recommended Posts