我正在尝试编写一个 .fits 格式的文件,据我所知,它需要 utf 编码,最好是 utf-8。如何将整数写入 utf-8 格式的文件?
最佳答案
How to encode a string in utf8 for std out:
myString = "string"
string.encode('utf8')
A python post by Jon Skeet on how to write to a file with utf8:
import codecs
file = codecs.open("lol", "w", "utf-8")
file.write(u'\ufeff')
file.close()
关于Python-编写utf-8有符号整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17677998/