简体   繁体   中英

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

I've created a pickle file through a python file:

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."

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. How can I make VS Code recognize a pickle file?

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. If you have a step-debugger you can execute arbitrary python code in VSC, you're better off using the function pickle.load inline.

Alternatively, you can create your own extension in VSCode to interpret pickled objects within a debugger.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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