Generation

generate functionSat, 22 Apr 2023

ingresar usando input un codigo de provedores, nombre de la empresa, nombre del agente, telefono de la empresa, telefono agente, guardar y leer datos en un archivo txt usando os y ast

import ast import os providers = {} def addprovider(codeprovider, name, agent, phonecompany, phoneagent): providers[codeprovider] = { 'name': name, 'agent': agent, 'phonecompany': phonecompany, 'phoneagent': phoneagent } with open('providers.txt', 'w') as f: f.write(str(providers)) def readproviders(): if not os.path.isfile('providers.txt'): return with open('providers.txt', 'r') as f: return ast.literal_eval(f.read()) def askproviders(): codeprovider = input('Enter the code of the provider') name = input('Enter the name of the provider') agent = input('Enter the name of the agent') phonecompany = input('Enter the number of the company') phoneagent = input('Enter the number of the agent') addprovider(codeprovider,

Questions about programming?Chat with your personal AI assistant