How to write (dump) and read (load) a list into binary file with Python

1 Answer

0 votes
import pickle

lst = ["c++", "php", "java", "python"]

# write
with open("d:\\lst.bin", "wb") as file:
    pickle.dump(lst, file)

# read
with open("d:\\lst.bin", "rb") as file:
    data = pickle.load(file)

print(data)


'''
run:
 
['c++', 'php', 'java', 'python']

'''

 



answered Nov 15, 2018 by avibootz

Related questions

1 answer 261 views
1 answer 172 views
1 answer 170 views
1 answer 235 views
...