asyncio 资料备忘
CPU Bound -- Multi Processing I/O Bound Fast I/O Limited Number of Connections -- Multi Threading I/O Bound Slow I/O Many Connections -- Asyncio
协程 coroutine
import asyncio
import datetime
async def getNow():
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
async def getRuntime():
v = await getNow()
print(v)
asyncio.run(getRuntime())
# 使用async关键字 声明异步方法
# 使用await关键字 等待协程执行完成
# 使用asyncio.run(某个async方法) 执行