本文实例讲述了python写入中英文字符串到文件的方法。分享给大家供大家参考。具体分析如下:
# -*- coding: utf-8 -*-
import codecs
content = u'你好,安科网 jb51.net'
f = codecs.open('c:/1.txt','w','utf-8')
f.write(content)希望本文所述对大家的Python程序设计有所帮助。
本文实例讲述了python写入中英文字符串到文件的方法。分享给大家供大家参考。具体分析如下:
# -*- coding: utf-8 -*-
import codecs
content = u'你好,安科网 jb51.net'
f = codecs.open('c:/1.txt','w','utf-8')
f.write(content)希望本文所述对大家的Python程序设计有所帮助。