Python中如何读取指定位置的TXT文件
f=open('C:\Users\hezhan\Desktop\hezhan.txt',"r")g=f.read()print(g)f.close()比如我放在桌面上,这...
f=open('C:\Users\hezhan\Desktop\hezhan.txt',"r")
g=f.read()
print(g)
f.close()
比如我放在桌面上,这样并不能打开,提示我 File
"<ipython-input-25-c89bd179aca5>", line 1
f=open('C:\Users\hezhan\Desktop\hezhan.txt',"r")
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape 展开
g=f.read()
print(g)
f.close()
比如我放在桌面上,这样并不能打开,提示我 File
"<ipython-input-25-c89bd179aca5>", line 1
f=open('C:\Users\hezhan\Desktop\hezhan.txt',"r")
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape 展开
展开全部
f=open('C:\\Users\\hezhan\\Desktop\\hezhan.txt',"r")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询