简体   繁体   English

有没有办法在 Visual Studio Code 中可视化泡菜文件?

[英]Is there a way to visualize pickle files in Visual Studio Code?

I've created a pickle file through a python file:我通过 python 文件创建了一个泡菜文件:

with open("pets.pickle", "wb") as file:
    pickle.dump(animal, file)

And then wanted to open it in Visual Studio Code, but I got this message: "The file is not displayed in the editor because it is either binary or uses an unsupported text encoding."然后想在 Visual Studio Code 中打开它,但我收到以下消息:“该文件未显示在编辑器中,因为它是二进制文件或使用了不受支持的文本编码。”

I was able to open it in Sublime Text though, and actually see the 0s and 1s, but I prefer to work with VS Code.虽然我能够在 Sublime Text 中打开它,并且实际上看到了 0 和 1,但我更喜欢使用 VS Code。 How can I make VS Code recognize a pickle file?如何让 VS Code 识别泡菜文件?

Thanks.谢谢。

Pickles are serialized data.泡菜是序列化的数据。 You cannot view them because they are binary representations.您无法查看它们,因为它们是二进制表示。 See the data stream format for the pickle module for more details.有关更多详细信息,请参阅 pickle 模块的数据 stream 格式 If you have a step-debugger you can execute arbitrary python code in VSC, you're better off using the function pickle.load inline.如果你有一个步进调试器,你可以在 VSC 中执行任意 python 代码,你最好使用 function pickle.load inline。

Alternatively, you can create your own extension in VSCode to interpret pickled objects within a debugger.或者,您可以在 VSCode 中创建自己的扩展来解释调试器中的腌制对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM