generate functionWed, 17 May 2023

crear un login y archivos Json

import json import os # function to create a user def create_user(username, password): if os.path.exists(username + ".json"): print("user already exists") else: with open(username + ".json", "w") as file: json.dump({ "username": username, "password": password, "balance": 0 }, file) # function to validate a user def validate_user(username, password): if os.path.exists(username + ".json"): with open(username + ".json") as file: data = json.load(file) if data["password"] == password: return True else: return False else: return False # function to deposit money def deposit_money(username, amount): if os.path.exists(username + ".json"): with open(username + ".json") as file: data = json.load(file) data["balance"] =

Questions about programming?Chat with your personal AI assistant