'How to save a python2.npz in python3

I have an application coding by Python2. I want to save a python2.npz in python3, So data can be readable by the application.

The application reading code:

            with open(fpath, 'rb') as file_:
            npz = np.load(file_)
            for _key in npz.files:
                res.__dict__[_key] = npz[_key]
            npz.close()

Especially, I don't know to encode object array.

'numpy.uint32' object has no attribute 'encode'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source