Python 的二进制文件读写需要注意的地方
# -*- coding: utf-8 -*-
#! /usr/bin/env python3
import os
ls=os.linesep
#write file
fobj=open('qq.txt','ab+')
subject='中文22'
subject = (subject+ls).encode('gb18030') #一定要把整个字符串进行转换为bytes
fobj.write(subject)
fobj.close()
print ('Done')