Python-编写utf-8有符号整数

标签 python utf-8

我正在尝试编写一个 .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/

相关文章:

python - Django 模板继承——缺少图像?

python - Selenium 文件上传失败,错误为 : "POST did not match a known command"

visual-studio - 如何更改 csharp 项目(Visual Studio/MSBuild 机器)中的源文件编码?

php - PHP 中 UTF-8 字符串的字节数组?

python - 从 Arduino 串行发送信号到 Python 程序

python - 如何比较两个文件并打印仅与第一个文件匹配的第二个文件

python - 如何从命令行使用 JSBeautify?

java - Java中如何检查一个字符是否来自特定的字符集?

python - 什么是 unicode 字符串?

python - 如何将utf-8输出重定向到txt文件