0

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.

1
  • RTFD. Commented Aug 1, 2015 at 19:02

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

2 Comments

Don't use the names of builtins for variables - it masks them and could lead to problems down the road.
@user2314737 just try dict = 1, then d = dict(foo=bar) and see what happens

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.