Monday 6 July 2020

How to transfer dict between python3 and python2?

A better way is to use npy file to transfer dict between python2 and python3, instead of json or pickle.

in python 3:-
np.save('temp.npy', data)

in python2:-
data = np.load('temp.npy',allow_pickle='TRUE').item()

(note that python 2 must upgrade numpy to latest version)

No comments:

Post a Comment