补全:并发收成列表
(每道题开头都有同一段:square(x) 是个协程,里面 await asyncio.sleep(0) 让出控制再返回 x*x;run_list(xs) 用 asyncio.gather 并发算每个的平方、按提交顺序回列表;run_sum 交回结果之和。判题机自带 asyncio。)
补全 run_list(xs):用事件循环跑 gather、交回结果列表。
(每道题开头都有同一段:square(x) 是个协程,里面 await asyncio.sleep(0) 让出控制再返回 x*x;run_list(xs) 用 asyncio.gather 并发算每个的平方、按提交顺序回列表;run_sum 交回结果之和。判题机自带 asyncio。)
补全 run_list(xs):用事件循环跑 gather、交回结果列表。
全部评论