简体   繁体   English

等待 aiofiles.os.remove() 返回 TypeError: object NoneType can't be used in 'await' expression

[英]awaiting for aiofiles.os.remove() returns TypeError: object NoneType can't be used in 'await' expression

I'm trying to remove a file from a local directory asynchronously;我正在尝试从本地目录中异步删除文件; however, I get the following error: object NoneType can't be used in 'await' expression ()但是,我收到以下错误: object NoneType can't be used in 'await' expression ()

I'm using ver aiofiles 0.5.0 and Python 3.6.5我正在使用版本 aiofiles 0.5.0 和 Python 3.6.5

my code is as straightforward as such:我的代码很简单:

async def delete_local_file(file_to_del):
    await aiof.os.remove(file_to_del)
    print("deleted: "+file_to_del)

await delete_local_file(localfile)

accidentally I used the wrong reference during import.不小心我在导入过程中使用了错误的参考。 simply use: import aiofiles.os只需使用:导入 aiofiles.os

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM