Generation

code to explanationSun, 18 Jun 2023

Função para apagar registro que recebe como parâmetro CPF e Apagar o Registro correspondente do arquivo.

def delete(cpf): for line in open("registro.txt", "r"): if line.split(',')[0] != cpf: f = open("registro1.txt", "a") f.write(line) f.close() os.remove("registro.txt") os.rename('registro1.txt', 'registro.txt')

Questions about programming?Chat with your personal AI assistant