Answers for "how to make a json file python"

13

json dump to file

import json

data = {"key": "value"}

with open('data.json', 'w') as jsonfile:
    json.dump(data, jsonfile)
Posted by: Guest on February-14-2020
4

how to create json file in python

#import the json module
import json 

#create a dictionary which we can add to a json file
dictionary ={ 
    "name" : "sathiyajith", 
    "rollno" : 56, 
    "cgpa" : 8.6, 
    "phonenumber" : "9976770500"
} 

#open an object with following inputs: 'name_of_file.json', 'w'
#dump the content fromt he dictionary into the outfile
with open("sample.json", "w") as outfile: 
    json.dump(dictionary, outfile)
Posted by: Guest on November-20-2020
1

write json pythonb

>>> jstr = json.dumps(data, ensure_ascii=False, indent=4)
>>> print(jstr)
{
    "item": "Beer",
    "cost": "£4.00"
}
Posted by: Guest on November-29-2019
0

create json file in python\

def check_splcharacter(test):
    # Make own character set and pass 
    # this as argument in compile method
 
    string_check= re.compile('[@_!#$%^&*()<>?/\|}{~:]')
 
    # Pass the string in search 
    # method of regex object.
 
    if(string_check.search(test) == None):
        print("String does not contain Special Characters.") 
    else: 
        print("String contains Special Characters.")
Posted by: Guest on June-10-2021

Code answers related to "how to make a json file python"

Code answers related to "Javascript"

Browse Popular Code Answers by Language