How to write a list to binary file in Python

1 Answer

0 votes
import pickle

lang = ["python", "c", "c++", "php"]
fh = open("d:\data.pkl", "bw")
pickle.dump(lang, fh)
fh.close()


'''
run:

d:\data.pkl
-----------
€]q (X   pythonqX   cqX   c++qX   phpqe.

'''

 



answered Dec 21, 2017 by avibootz

Related questions

1 answer 204 views
1 answer 261 views
1 answer 189 views
1 answer 159 views
1 answer 250 views
...