# -*- coding: utf-8 -*-"""windows cmd下运行通过windows - python(x,y)下运行通过mac pycharm运行通过"""import codecsfp = codecs.open('test utf8.txt', 'w', 'utf-8')fp.write(u"你好,世界!")fp.close()fp = codecs.open('test utf8.txt', 'r', 'utf-8')print fp.readline()fp.close()print u'你好,世界! from print u"XX"'fp = codecs.open('test gb2312.txt', 'w', 'gb2312')fp.write(u"你好,世界!")fp.close()fp = codecs.open('test gb2312.txt', 'r', 'gb2312')print fp.readline()fp.close()raw_input()