Answers for "# write json file"

0

# write json file

# write json file
import json
d = {
    "firstName": "Tom",
    "lastName": "Jack",
    "gender": "male",
    "age": 35,
    "address": {
        "streetAddress": "126",
        "city": "San Jone",
        "state": "CA",
        "postalCode": "95150"
    },
    "phoneNumbers": [
        { "type": "home", "number": "4083627627" }
    ]
}

filename = "/content/sample_data/sample1.json"
with open(filename, 'w') as f:
  json.dump(d, f)
Posted by: Guest on March-30-2022

Python Answers by Framework

Browse Popular Code Answers by Language