Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

save dictionary to file numpy

import numpy as np

d1={'key1':[5,10], 'key2':[50,100]}
np.save("d1.npy", d1)
d2=np.load("d1.npy")
print d1.get('key1')
print d2.item().get('key2')
Comment

numpy save dict to txt

import numpy as np

# Save
dictionary = {'hello':'world'}
np.save('my_file.npy', dictionary) 

# Load
read_dictionary = np.load('my_file.npy',allow_pickle='TRUE').item()
print(read_dictionary['hello']) # displays "world"
Comment

PREVIOUS NEXT
Code Example
Python :: change default option optionmenu tkinter 
Python :: post request in python flaks 
Python :: aiohttp get 
Python :: scapy python import 
Python :: pip install django rest framework 
Python :: numpy remove element 
Python :: pandas count freq of each value 
Python :: find the first occurrence of item in a list in python 
Python :: dataframe column data type 
Python :: python get position of character in string 
Python :: remove special characters from string python 
Python :: np.rand.randint 
Python :: Django Check hashed Password 
Python :: selenium get parent element python 
Python :: 2 for loops at the same time in Python 
Python :: python set comparison 
Python :: how to get only certain columns in pandas 
Python :: save dataframe to a csv local file pyspark 
Python :: python list all files of directory in given pattern 
Python :: Insert missing data in pandas 
Python :: bytes to kb mb gb python 
Python :: dir template 
Python :: check pygame version 
Python :: lambda function with if elif else python 
Python :: how to create empty series in pandas 
Python :: upgrade python wsl 
Python :: combine two dictionary adding values for common keys 
Python :: python string to list with separator 
Python :: how to display address in python 
Python :: malier module python 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =