Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The following is my code:

import json
id = "iderq23512345123521"
with open("file.json", "r+") as f:

        data = json.loads(f.read())
        f.truncate(0)
        del data[id]
        data = json.dumps(data)
        f.write(subs)

This is what the file looks like after I do it

When I try to copy and paste the characters, they don't show up


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
223 views
Welcome To Ask or Share your Answers For Others

1 Answer

Rename the id variable to something else (like id2), id already is a python func


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...