Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个CSV看起来像这样的文件:
CSV
[num]_[num] [num] [string]
例如:
1234_123 987 Hello World
我想将此数据保存在二进制文件中,以某种方式维护相应的行结构。 有任何想法吗?
嗯
import base64 with open("output.bin","w") as f: f.write(base64.b64encode(open("input.txt")
如果您想以人类无法阅读的方式保存它(如果这就是二进制格式的意思)
然后解码回来
import base64 original_txt = base64.b64decode(open("output.bin").read())