我想在jupyter笔记本上运行我的程序,这个程序在特定的时间停止(例如18:00)。我用时间循环和增量索引编写了程序,但最好用时间参数来编写。
我每天运行上述程序7个小时。它必须不间断地运行。
while(i<500000):
execute algorithm
i+=1但我想像这样运行我的程序:
while(not 18:00 clock):
execute algorithm发布于 2019-03-22 07:49:49
让我们假设您希望代码每天运行10分钟(22:oo)。如果您使用的是Linux,您可以这样做,以root用户的身份运行作业。
sudo crontab -e
0 22 * * * /path/to/directory/python my_code.py您的python文件my_code.py可能是这样的。
# python code to search pattern in a string using regex
import re
str1 = 'this is {new} string with [special] words.'
r = re.search(r'\{(.*?)\}', str1)
if r:
found =r.group()
else:
"No match found"
print foundhttps://stackoverflow.com/questions/55287184
复制相似问题