【发布时间】:2023-02-18 18:24:17
【问题描述】:
我想异步获取当前时间
我有代码:
async def get_hour():
return datetime.datetime.now().hour
async def timer():
while True:
print(await get_hour())
await asyncio.sleep(60)
asyncio.run(timer())
他正在工作,但另一个代码不异步工作。
【问题讨论】:
标签: python python-3.x datetime asynchronous python-asyncio