save dict to txt python code example
Example 1: how to save dict in txt format
dict = {'Python' : '.py', 'C++' : '.cpp', 'Java' : '.java'}
f = open("dict.txt","w")
f.write( str(dict) )
f.close()
Example 2: python save dictionary as text
with open('myfile.txt', 'w') as f:
print(mydictionary, file=f)