Erik Augustyn
Erik Augustyn

Reputation: 11

Writing JSON data to file in python

I'm not quite sure on how you write a JSON so can you please help me, i'm trying to make this with JSON in python. Here's the pseudo-code

binary_students = json(students)

write_to_the_file_system(binary_students)

I'm not quite understanding it, can someone help me please.

Upvotes: 0

Views: 108

Answers (1)

user2314737
user2314737

Reputation: 29307

You can use a dictionary for storing Json data like this:

>>> dict = {'Student1':'x1','Student2':'x2'}

and then use the jsonlibrary

>>> import json
>>> with open('data.txt', 'w') as outfile:
    json.dump(dict,outfile)

Upvotes: 1

Related Questions