python跨平台的pickle文件? [英] Is pickle file of python cross-platform?
问题描述
是python是coss平台,但是pickle文件不是。
有没有解决这个问题的方法???
Python的pickle是完全跨平台的。 >
这可能是由于Windows和Linux之间的EOL(行尾)差异造成的。确保以二进制模式打开你的pickle文件,在写入和阅读时分别使用open()的wb和rb模式。
注意:在不同版本的Python之间传递pickle可能会造成麻烦,所以请尝试在两个平台上使用相同版本。
I have created a small python script of mine. I saved the pickle file on Linux and then used it on windows and then again used it back on Linux but now that file is not working on Linux but it is working perfectly on windows. Is is so that python is coss-platform but the pickle file is not. Is there any solution to this one???
Python's pickle is perfectly cross-platform.
This is likely due to EOL (End-Of-Line) differences between Windows and Linux. Make sure to open your pickle files in binary mode both when writing them and when reading them, using open()'s "wb" and "rb" modes respectively.
Note: Passing pickles between different versions of Python can cause trouble, so try to have the same version on both platforms.
这篇关于python跨平台的pickle文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!