python3的pickle导致乱码

资料:

  http://www.cnblogs.com/pzxbc/archive/2012/03/18/2404715.html

  http://bbs.chinaunix.net/thread-4192876-1-1.html

pickle.dump(obj, file, [,protocol])

def fun2(file_name, mylist):
    file = open(file_name, 'wb')
    pickle.dump(mylist, file, 0)
    file.close()

为了避免保存的file乱码,在dump()里加上第三个参数,设为0(ASCII协议).

posted @ 2016-12-16 17:02  billyz  阅读(6380)  评论(0编辑  收藏  举报