发布时间:2019-09-06 08:59:50编辑:auto阅读(2067)
python 从3.5开始从语言层面提供了新的异步编程语法。
import asyncio async def hello(): print("hello the world") r = await asyncio.sleep(1) print("hello again") def main(): loop = asyncio.get_event_loop() """ tasks = [ asyncio.ensure_future(hello()), ] loop.run_until_complete(asyncio.wait(tasks)) """ print("begin") loop.run_until_complete(hello()) print("end") loop.close() print("program is finished.") if __name__ == "__main__": main()
上一篇: python文件读写(open参数,文件
下一篇: python websocket cli
47863
46424
37314
34760
29332
25990
24945
19967
19564
18050
5806°
6433°
5947°
5975°
7080°
5926°
5963°
6456°
6418°
7798°