Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try:
- with open("database.json", "r+") as datahere:
- db = json.load(datahere)
- except:
- print("Database file not found / corrupted!")
- def jsondump(update):
- new_user_id = update.message.from_user.id
- try:
- if new_user_id not in db:
- user = {
- "%r" % new_user_id:
- [
- {"NAME": ""},
- {"AGE": 00},
- {"BIO": ""},
- {"INTERESTS": []},
- {"PICTURE_PATH": ""}
- ]
- }
- with open("database.json", "r+") as dataload:
- data = json.load(dataload)
- data.update(user)
- with open("database.json", "r+") as datadump:
- json.dump(data, datadump, indent=4)
- except:
- print("Json data write failed!")
- def test(bot, update):
- id1 = str(update.message.from_user.id)
- test2 = db[id1][NAME] = "HELL" # this doesn't stick in the file at all
- json.dump(test2, db)
- --------------------------------FILE--------------------------------------------
- {
- "91495773": [
- {
- "NAME": ""
- },
- {
- "AGE": 0
- },
- {
- "BIO": ""
- },
- {
- "INTERESTS": []
- },
- {
- "PICTURE_PATH": ""
- }
- ]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement