Python 3.5:“與...同步”會(huì)導(dǎo)致SyntaxError。為什么?[重復(fù)]
asyncwith沒有async功能就不能使用。正如文檔所說:
與async def函數(shù)一起使用async是SyntaxError。
但是此代碼將起作用:
async def some_function(): async with aiohttp.ClientSession() as session:pass
或看看docs中的示例。
解決方法我正在使用Python 3.5,根據(jù)PEP492,它應(yīng)該可以訪問該asyncwith語(yǔ)法,但是在嘗試使用它時(shí)卻收到了SyntaxError。我究竟做錯(cuò)了什么?
In [14]: sys.versionOut[14]: ’3.5.2 (default,Oct 11 2016,04:59:56) n[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)]’In [15]: async with aiohttp.ClientSession() as session: File '<ipython-input-15-9799c5ce74cf>',line 1 async with aiohttp.ClientSession() as session: ^SyntaxError: invalid syntax
相關(guān)文章:
1. 刪除docker里建立容器的操作方法2. 使用 kind 和 Docker 啟動(dòng)本地的 Kubernetes環(huán)境3. IntelliJ IDEA導(dǎo)出項(xiàng)目的方法4. Docker容器如何更新打包并上傳到阿里云5. IntelliJ IDEA設(shè)置條件斷點(diǎn)的方法步驟6. Docker究竟是什么 為什么這么流行 它的優(yōu)點(diǎn)和缺陷有哪些?7. idea自定義快捷鍵的方法步驟8. jsp中sitemesh修改tagRule技術(shù)分享9. Django中如何使用Channels功能10. idea設(shè)置代碼格式化的方法步驟

網(wǎng)公網(wǎng)安備