马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
代码写成这样就报错:import asyncio
async def hanshu1():
a = [1,2,3]
b = [4,5,6]
return a,b
async def main(fbi,cis):
print(fbi,cis)
t1 = asyncio.run(hanshu1())
fbi_list = t1[0]
cis_list = t1[1]
task1 = [main(fbi) for fbi in fbi_list]
task2 = [main(cis) for cis in cis_list]
asyncio.run(asyncio.wait(task1,task2))
我想往main函数中传两个参数,如果传一个代码如下是正常的,但是传两个肯定是我写的不对,哪位高手能帮忙指点一下,谢谢import asyncio
async def hanshu1():
a = [1,2,3]
b = [4,5,6]
return a,b
async def main(fbi):
print(fbi)
t1 = asyncio.run(hanshu1())
fbi_list = t1[0]
# cis_list = t1[1]
task1 = [main(fbi) for fbi in fbi_list]
asyncio.run(asyncio.wait(task1))
main 函数你设置了两个参数,只传入了一个
你试试这样行不:
import asyncio
async def hanshu1():
a = [1,2,3]
b = [4,5,6]
return a,b
async def main(fbi,cis):
print(fbi,cis)
t1 = asyncio.run(hanshu1())
fbi_list = t1[0]
cis_list = t1[1]
temp = list(zip(fbi_list,cis_list))
task1 = [main(fbi,cis) for fbi,cis in temp]
asyncio.run(asyncio.wait(task1))
|