#Write a string

contents = {"aa": 12, "bb": 21}
with open("myfile1.txt", "w+") as file:
    file.write(str(contents))

#Read a string

with open('myfile1.txt', "r+") as file:
    contents = file.read()
print(contents)
Comments