python文件操作错误解决

1.

python读取文件时提示"UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multibyte sequence"

解决办法1.

  OBJECT= open('account.html','r', encoding='UTF-8')

解决办法2.

  OBJECT= open('account.html','rb')

2.

python读取文件时提示 "SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape"

方式一:转义的方式  : 'd:\\a.txt'

方式二:使用Linux的路径 /  : 'd:/a.txt'

posted @ 2018-03-10 15:52  刘建东  阅读(368)  评论(0编辑  收藏  举报