Python pickle的首选(或最常见)文件扩展名 [英] Preferred (or most common) file extension for a Python pickle
问题描述
这是一个学生提出的问题,我没有一个很好的答案.有时,对于包含Python泡菜但不确定最常见或最佳做法的文件,我曾见过.pickle
,.pck
,.pcl
和.db
.我知道后三个扩展也用于其他用途.
This is a question from a student that I didn't have a good answer for. At times, I've seen .pickle
, .pck
, .pcl
, and .db
for files that contain Python pickles but am unsure what is the most common or best practice. I know that the latter three extensions are also used for other things.
相关的问题是,使用REST API在系统之间发送酱菜时,首选哪种MIME类型?
The related question is what MIME type is preferred for sending pickles between systems using a REST API?
推荐答案
Python 2
从 Python 2文档:
output = open('data.pkl', 'wb')
在使用Python 2时,我会选择.pkl
作为扩展名.
I would choose .pkl
as the extension when using Python 2.
Python 3
Python 3文档中的示例现在使用.pickle
作为文件扩展名:
The example in the Python 3 docs now uses .pickle
as the file extension:
with open('data.pickle', 'rb') as f:
从以下martineau的评论中发送咸菜的首选MIME类型:
The MIME type preferred for sending pickles from martineau's comment below:
应用程序/八位字节流
application/octet-stream
这篇关于Python pickle的首选(或最常见)文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!