Miscellaneous Functionalities
Writing into a File
Writing a .txt File
# saving a text file
with open("file_name.txt", "w") as output:
output.write(str(content))
Writing to a JSON File
# saving a json file
import json
with open('file_name.json', 'w') as f:
json.dump(content, f)
Reading a File
Reading a JSON File
import json
# Opening JSON file
f = open('file_name.json',)
# returns JSON object as a dictionary
data = json.load(f)
Last updated
Was this helpful?