How to create utf-8 files in python?
三叔
三叔 2017-06-14 10:53:28
0
2
933
# coding=utf-8 ##以utf-8编码储存中文字符
import os
import codecs

path = "d:/Python/c.txt"
try:
    f=codecs.open(path,'w', 'UTF-8')
    f.close()
except Exception as e:
    print(e)
os.system('pause')

Python 3.6.1

The above code can only create text files in ANSI format. How to create UTF-8 files?

三叔
三叔

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!