-2
I’m creating a simple system to query employee data stored in a file txt
.
def read_from_file():
with open('dados.txt') as file:
for line in file:
line = line.rstrip('\n')
nome, matricula, supervisor, email, chave, local, centrodecusto = line.split('/')
base_dados[nome] = matricula, supervisor, email, chave, local, centrodecusto
def write_to_file(nome_data, matricula_data, supervisor_data, email_data, chave_data, local_data, centrodecusto_data):
with open('dados.txt') as file:
file.write('\n' + nome_data + '/' + matricula_data + '/' + supervisor_data + '/' + email_data + '/' + chave_data + '/' + local_data + '/' + centrodecusto_data )
read_from_file()
while True:
query_nome = simpledialog.askstring('Dados empregados', 'Digite o nome do empregado: ')
if query_nome in base_dados:
result = base_dados[query_nome]
messagebox.showinfo ('Answer',
'teste' + query_nome + 'teste' + result + 'teste')
root.mainloop()
But code returns me the following error:
File "path", line 24, in 'test' + query_name + 'test' + result + 'test') Typeerror: must be str, not tuple
Could you help me?
result = base_dados[query_nome]
is returning a tuple.– Augusto Vasques