【发布时间】:2017-11-08 07:14:42
【问题描述】:
在 python 中,while 循环超时的最佳方法是什么
说:
while not buff.endswith('/abc #'):
10 秒后,如果不匹配,则中断循环。
谢谢
【问题讨论】:
-
请更清楚地说明问题。你想在 10 秒后打破
while循环吗? -
我很惊讶没有人建议使用某种
sleep来防止代码阻塞其他线程。buf是异步填充的吗?
标签: python python-2.7