Save files in python
Go to solution
Solved by mikat,
39 minutes ago, Pythons said:Hmmm, maybe.
I was thinking about just using normal python without downloading anything!
you don't have to, you can just do this:
read:
import json
with open('JSONData.json', 'r') as f:
data = json.load(f)
print(data)
write:
import json
data = {
"name":"Pythons",
"type":"Linus Tech Tips User"
}
#json.dumps() method turns a Python data structure into JSON:
jsonData = json.dumps(data)
print(jsonData)
# Writing JSON data into a file called JSONData.json
#Use the method called json.dump()
#It's just dump() and not dumps()
#Encode JSON data
with open('JSONData.json', 'w') as f:
json.dump(jsonData, f)

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now