Billy
Billy

Reputation: 51

Python save variable to file like save() in MATLAB

I just new in python. How to save variable data to file like save command in MATLAB.

Thank you

Upvotes: 2

Views: 2000

Answers (2)

Billy
Billy

Reputation: 51

Thx TheBlackCat

Example my code

try:
    import cPickle as pickle  # Improve speed
except ValueError:
    import pickle

file_temp = open('temp', 'w')
pickle.dump(scenes, file_temp)
file_temp.close()

Upvotes: 1

TheBlackCat
TheBlackCat

Reputation: 10298

Use pickle.dump in Python 3.x, or cPickle.dump in Python 2.x.

Upvotes: 2

Related Questions