Create a dictionary of 5 pairs of key: value (Done)

And save this dictionary in json format (It seems ready)

Save to text file (output.txt) (Not Ready)

json.dumps({"Login":"dima", "Password":123, "email":123123, "Country":"Russia", "City":"Moscow"},sort_keys=True) 

    1 answer 1

    json.dumps() returns text that can be saved to a file:

     import pathlib pathlib.Path("путь").write_text(text, encoding="utf-8") 

    or directly call json.dump() to save to the file immediately on the fly :

     import json with open("путь", "w", encoding="utf-8") as file: json.dump(data, file)