Ingresar datos documento txt Python

def crear():
    archivo=open("datos.txt","w")
    archivo.close()
   
 
def escribir():
    archivo=open("datos.txt","a")
    nombre = str(input("ingrese el nombre"))
    apellido = str(input("Ingrese el apellido"))
    archivo.write(nombre+","+apellido+"\n")
    archivo.write("Fin Del Archivo")
    archivo.close()
def leer():
    archivo=open("datos.txt","r")
    registro=archivo.readline()
    while registro!="":
          print(registro)
          registro=archivo.readline()
    archivo.close()
def leerlista():
    archivo=open("datos.txt","r")
    registros=archivo.readlines()
    for lineas in registros:
        print(registros)
         
#crear()
#escribir()
leer()
leerlista() 

Share this

Related Posts

Previous
Next Post »