OSError: [Errno 22] Invalid argument: 'test\x07lice.txt'

 

使用with open("text\alice.txt","rt") as file_object:报上面的错误:

OSError: [Errno 22] Invalid argument: 'test\x07lice.txt'

 

将上面的语句改成

with open(r"text\alice.txt","rt") as file_object:

字符串前面加r,表示的意思是禁止字符串转义

posted @ 2020-03-17 20:12  Danniel_gong  阅读(468)  评论(0编辑  收藏  举报