Is it possible to save python dictionary into json files?

0 votes
i have a dictionary in Python and I want to save it in json file. How to achieve this?
Sep 4 in Python by Arvind
• 2,960 points

1 answer to this question.

0 votes

Suppose you have a dictionary in python say my_dict = {'a':11,'b':22,'c':33}. Refer to the following code - 

import json
my_dict = {'a':11,'b':22,'c':33}
with open("your_json_file", "w") as fp:

json.dumps is mainly used to display dictionaries as a json format with the type of string. While dump is used for saving to file

answered Sep 4 by Neel
• 3,010 points

Related Questions In Python

0 votes
1 answer

Is it possible in Python requests to print entire HTTP request?

A better idea is to use the ...READ MORE

answered Nov 26, 2018 in Python by Nymeria
• 3,520 points
0 votes
1 answer

is it possible to do method overloading in python?

You cannot have two methods with the ...READ MORE

answered Mar 25 in Python by Mohammad
• 3,060 points
0 votes
1 answer

Is it possible to create an array with all values as zero in python?

You can use  np.zeros(4,3) This will create a 4 ...READ MORE

answered May 24 in Python by Anjali
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 348 views
+4 votes
6 answers
0 votes
1 answer

Is it possible to run a function in Python using the command line?

Suppose your file name is and ...READ MORE

answered Jun 26 in Python by Neel
• 3,010 points
+1 vote
1 answer

is it possible to compare a values to a backslash in Python?

The backslash "\" character is used to ...READ MORE

answered Jun 28 in Python by Neel
• 3,010 points