#coding=utf-8f = open("test.txt",'w+')f.write('Mars is slim,isn\'he? \n 火星教')print f.read()f.close()
#coding=utf-8#这样写,对文件进行读写操作之后打开记事本不会乱码f = open("test.txt",'w+')f.write('Mars is slim,isn\'he? \n 火星教')f.close()f = open("test.txt").decode('utf-8')print f.read()f.close()