问题集合


##1
python 3以上版本使用pickle.load读取文件报UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0x8b in position 6
2017年03月18日 17:53:061832人阅读 评论(1) 收藏 举报
原本代码是这样的

fo = open(file, 'rb')
dict = pickle.load(fo)

修改之后只需要在打开的时候指定编码

fo = open(file, ‘rb’)
dict = pickle.load(fo,encoding=’iso-8859-1’)

##
import time

time_start=time.time()
time_end=time.time()
print(‘totally cost’,time_end-time_start)