84669 人が学習中
152542 人が学習中
20005 人が学習中
5487 人が学習中
7821 人が学習中
359900 人が学習中
3350 人が学習中
180660 人が学習中
48569 人が学習中
18603 人が学習中
40936 人が学習中
1549 人が学習中
1183 人が学習中
32909 人が学習中
s = u'中文' f = codecs.open('ufile.log', 'w', "UTF-8") f.write(s) f.close()
Python中如何将文件保存为utf-8(带BOM)的格式,如果使用以下代码,则文件的格式为:utf-8无BOM
学习是最好的投资!
f = codecs.open('ufile.log', 'w', 'utf_8_sig')
参见: 7.8.6. encodings.utf_8_sig — UTF-8 codec with BOM signature
参见: 7.8.6. encodings.utf_8_sig — UTF-8 codec with BOM signature