我试图在循环中执行以下功能
def post_webhook(payload):
if not WEBHOOK_URL:
print "WEBHOOK_URL isn't setted"
return
try:
json = {'data': payload}
print "webhook_url:", WEBHOOK_URL
r = requests.post(WEBHOOK_URL, data=json)
print "requests.post:", r.text
except Exception as e:
print "post_webhook err:", e
像这样
while True:
post_webhook(payload)
但是,post_webhook函数只执行一次
当我在while循环中调用post_webook()时,print "requests.post:", r.text
不会在post_webhook()
因此,r = requests.post(WEBHOOK_URL, data=json)
只在循环中执行一次,我想在循环中多次执行post_webhook()
为什么request.post只在循环中执行一次?