第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

需要 Future 或協(xié)程 - asyncio

需要 Future 或協(xié)程 - asyncio

紅糖糍粑 2022-12-20 09:58:15
我正在嘗試異步加載網(wǎng)頁內(nèi)容。我使用過requests_html,因?yàn)槲以诜?wù)器上安裝它時(shí)遇到一些問題所以我使用asyncio@asyncio.coroutineasync def extract_feature():    try:        count = 0        key = ''        loop = asyncio.get_event_loop()        response = await loop.run_in_executor(None, requests.get, link)        soup = BeautifulSoup(response, "html.parser")        return souploop = asyncio.get_event_loop()result = loop.run_until_complete(extract_feature)但這會(huì)引發(fā)A Future 或 coroutine is required。要提到的一件事是我使用的是不支持運(yùn)行的Python 3.5.0 (v3.5.0:374f501f4567) 。
查看完整描述

1 回答

?
狐的傳說

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超3個(gè)贊

您需要extract_feature在將其傳遞給之前致電run_until_complete,即:

result = loop.run_until_complete(extract_feature())

此外,asyncio.coroutine裝飾器不應(yīng)該與已經(jīng)定義為的函數(shù)一起使用async def——忽略它即可。


查看完整回答
反對(duì) 回復(fù) 2022-12-20
  • 1 回答
  • 0 關(guān)注
  • 114 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)