我阅读了木星教程Index
并尝试
In [15]: print('before sleep'); sleep(12); print('after sleep')
before sleep
/home/me/anaconda3/bin/ipython:1: RuntimeWarning: coroutine 'sleep' was never awaited
#!/home/me/anaconda3/bin/python
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
after sleep
对于警告非常困惑,
答案 0 :(得分:0)
此错误意味着从未执行过“睡眠”功能(实际上是协程)。
尝试将其替换为:
asyncio.get_event_loop().run_until_complete(sleep(25))
否则,只需使用非异步睡眠方法:
import time
time.sleep(25)
祝你好运!