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,表示的意思是禁止字符串转义

猜你喜欢

转载自www.cnblogs.com/danniel-gong/p/12513029.html
今日推荐