python - use variables as key names when using numpy savez -
After loading an npz file, I like to be able to use arrays with keys, for example:
KEY1 = "names" file = np.load (npzFilename) data = file [KEY1] But when you save, you have to manually The form must be emphasized, i.e.:
np.savez (npzFilename, name = name) Does any one NPZ dictionary key have a variable Is set to use?
np.savez (npzFilename, name, key = key1)
You can use a dictionary:
vals_to_save = {KEY1: name} np.savez (npzFilename, ** vals_to_save) Where you want to programmatically set up vals_to_save as the desired speaker
Comments
Post a Comment