gpt4 book ai didi

python - Python pickle 的首选(或最常见)文件扩展名

转载 作者:IT老高 更新时间:2023-10-28 20:31:05 27 4
gpt4 key购买 nike

有时,我见过 .pickle.pck.pcl.db对于包含 Python pickle 的文件,但我不确定什么是最常见或最佳实践。我知道后三个扩展也用于其他用途。

相关问题是:使用 REST API 在系统之间发送 pickle 时首选哪种 MIME 类型?

最佳答案

Python 2

来自 Python 2 documentation ,在序列化(即写入 pickle 文件)时,使用:

output = open('data.pkl', 'wb')

在使用 Python 2 时,我会选择 .pkl 作为扩展名。

Python 3

Python 3 documentation 中的示例现在使用 .pickle 作为序列化的文件扩展名:

with open('data.pickle', 'wb') as f:
pickle.dump(...)

martineau's comment 发送 pickle 时首选的 MIME 类型下面:

application/octet-stream

What is the HTTP "content-type" to use for a blob of bytes?

关于python - Python pickle 的首选(或最常见)文件扩展名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40433474/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com