我有带有通知的监视python脚本
这是我的脚本
if COUNT != 0:
print("Running!")
text = process[0] + " process running"
url = URL + "sendMessage?text={0}&chat_id={1}".format(text, CHAT_ID)
# send message to groups
requests.get(url)
如何在条件为true时保持循环并仅发送一次消息
答案 0 :(得分:0)
你的意思是这样吗?
condition=True
while condition:
if COUNT != 0:
print("Running!")
text = process[0] + " process running"
url = URL + "sendMessage?text={0}&chat_id={1}".format(text, CHAT_ID)
# send message to groups
requests.get(url)
condition=False
答案 1 :(得分:0)
flg = True
while COUNT != 0:
print("Running!")
if flg:
text = process[0] + " process running"
url = URL + "sendMessage?text={0}&chat_id={1}".format(text, CHAT_ID)
# send message to groups
requests.get(url)
flg = False
您可以使用flg变量使消息发送代码仅运行一次。