import json dict1 = {'name': 'fam', 'age': 19} print(type(json.dumps(dict1))) f = open('fan.txt', 'w') json.dump(dict1, f) f.close()