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

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -