Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import sys as q
- def Json_file_read():
- file_name = input("(with the current state it must be in the same directory)\n.json file name: ")
- with open(file_name, "r", encoding="utf-8") as our_opened_file:
- data_base = json.load(our_opened_file)
- print(f"{file_name} Load Successful")
- if input("Wanna see the file? (y/n)") == "y" or "y".upper():
- print(data_base)
- else:
- home_text()
- def Json_file_dump():
- save_file_name = input("Save as: ")
- value_numb = int(input("Give me the Value number \n: "))
- i = 0
- z = []
- key = input("Give me the key name : ")
- XO = {key:[]}
- while i < value_numb:
- value = input(f"Give me the {i} Value name : ")
- z.append(value)
- XO[key].append(z)
- i += 1
- print(XO)
- with open(save_file_name, "w", encoding="utf-8") as save_file:
- json.dump(XO, save_file, ensure_ascii=False, indent=2)
- print("SAVE WAS SUCCESSFUL ")
- #data = json.dumps(data_base, ensure_ascii=False, indent=2)
- def home_text():
- print("\nIn this Python project you can do literally nothing with Json file's")
- if input("1.) File Read\n2.) File Create ('JSON')\n3.) Quit\nWhat do you want: ") == "1":
- Json_file_read()
- elif "2":
- Json_file_dump()
- else:
- q.exit("BRO")
- #Json_file_dump()
- home_text()
Advertisement
Add Comment
Please, Sign In to add comment