python3打开winodows文件问题

1,解决办法
 "C:\\Users\\Darkness-02\\Desktop\\test.txt"

多加一个反斜杠就行了

2,解决办法
r"C:\Users\Darkness-02\Desktop\txt.txt"
变为字符串

 

玩具

with open("C:\\Users\\Darkness-02\\Desktop\\test.txt","r") as txt:
    print(txt.read())

with open(r"C:\Users\Darkness-02\Desktop\txt.txt","r") as txt:
    print(txt.read())

 

posted @ 2018-04-20 09:57  三天泪  阅读(363)  评论(0编辑  收藏  举报