Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

how do I write and read json obj to a file

$
0
0
down vote favorite


I am new to json & have limited knowledge of python.

I am trying to make a class which reads & write JSON object to file taking 1 argument of dictionary type.

class Student:

    def __init__(self,name,email,contact,skills,ug=None,pg=None):

        self.email=email
        self.contact=contact
        self.name=name
        self.skills=[skills]

        self.edu={"ug":[ug],"pg":[pg]} 

james=Student("James","j@j.com","+1 7789990007","Python","CS", "CS")

print vars(james)


I am getting invalid syntax error (I am using eclipse IDE & PyDev plugin) but the output is coming on http://codepad.org/5tRBiJKj

Now how do I write and read this to a file ?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>