在试图打开docx文档内容时,以为可以向读取txt文档一样,于是写下了下面的代码
with open('C:\\Users\\Administrator\\Desktop\\案例二.docx','r')as f:
contents = f.read()
print(contents)
结果遇上报错:UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xe3 in position 55: illegal multibyte sequence
解决方法一:
一看,编码错误,祖传方法encoding=’utf-8‘’百试百灵的修改
with o
在写爬虫,往csv写入文件时候报错
'gbk' codec can't encode character '\U0001f370' in position 5: illegal multibyte sequence
去一看名字我懵逼了是个emoji????
原来代码是这么写的
设置csv文件位UTF-8,代码改为
for i in b:
persons = str(i).replace('u','').replace('\'','')
print(persons)
wit
base64找不到下面连个jar包也可以解决
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
报错:
Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required library C:\Java\jre1.6.0_07\lib\rt.jar
此时解决办法:
Eclipse默认把这些受访问限制的API设成了ERROR。只要把Windows-Preferences-Java-Complicer-Errors/Warnings里面的Deprecated and restricted API中的Forbidden references(access rules)选为Warning就可以编译通过。