- #-*-coding: utf-8 -*-
- import codecs
- u = u'代码片段'
- ll = [u]
- #f = codecs.open('test1.txt', 'w', encoding='UTF-8')
- f = open('test1.txt', 'w')
- f.write(u)
- f.write('%s'%ll)
- f.write('['+'%s'%u+']')
- f.write('['+'%r'%u+']')
- f.close()
- #该片段来自于http://www.codesnippet.cn/detail/271120137537.html
来源: http://www.codesnippet.cn/detail/271120137537.html