Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python write a dictionary to file

dictionary = {'someKey' : 'someValue'}
file_path = 'somePathToFile/someFileName.py'
with open(file_path, 'w') as output_file:
    print(dictionary, file=output_file)
Comment

how to write and read dictionary to a file in python

# Writing dictionary as json
import json
d = {'guitar':'Jerry', 'drums':'Mickey' }
json.dump(d, open('1.json', 'w'))
Comment

how to write and read dictionary to a file in python

# Reading dictionary from a json file
json.load(open('1.json', 'r'))
Comment

PREVIOUS NEXT
Code Example
Python :: how to logout in django 
Python :: numpy weighted average 
Python :: python loop go back to start 
Python :: textclip python arabic 
Python :: list from comma separated string python 
Python :: python list of dictionaries to excel 
Python :: python append filename to path 
Python :: python how to draw triangle 
Python :: ipynb to pdf cide 
Python :: [0] * 10 python 
Python :: discord.py mention user 
Python :: contextlib.subppress python 
Python :: python dict get random key 
Python :: python draw circle matplotlib 
Python :: oython 
Python :: how to downgrade python 3.9 to 3.8 
Python :: pandas unique values to list 
Python :: midpoint 
Python :: excute a command using py in cmd 
Python :: python cocktail sort 
Python :: get_dummies 
Python :: test_size 
Python :: discord.py send image from url 
Python :: divisible in python 
Python :: how to create a variablein python 
Python :: python tkinter text get 
Python :: how to do a print statement in python 
Python :: python plot two lines with different y axis 
Python :: how to get local ip in python 
Python :: How to know size of Python list 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =