1#import the json module
2import json
3
4#create a dictionary which we can add to a json file
5dictionary ={
6 "name" : "sathiyajith",
7 "rollno" : 56,
8 "cgpa" : 8.6,
9 "phonenumber" : "9976770500"
10}
11
12#open an object with following inputs: 'name_of_file.json', 'w'
13#dump the content fromt he dictionary into the outfile
14with open("sample.json", "w") as outfile:
15 json.dump(dictionary, outfile)
1def check_splcharacter(test):
2 # Make own character set and pass
3 # this as argument in compile method
4
5 string_check= re.compile('[@_!#$%^&*()<>?/\|}{~:]')
6
7 # Pass the string in search
8 # method of regex object.
9
10 if(string_check.search(test) == None):
11 print("String does not contain Special Characters.")
12 else:
13 print("String contains Special Characters.")