1
Hi. I’m sorry about the basic question, but I started dealing with python a week ago. I’m writing a program that records candidates' votes in a binary file. But, at the time of displaying I am not finding a way to leave "beautiful". I would like to appear only the Name and the Number of votes. Follows code:
arquivo = open('C:\Users\Cassio\Documents\Python Programs\eleicao.dat', 'rb')
print ('Os votos dos candidatos serao exibidos a seguir: ')
for x in range(cont):
aux = pickle.load(arquivo)
print('O candidato(a): ', aux['NOME'], 'tem: ', aux['NUM_VOTOS'], 'votos.')
arquivo.close()
Follow the exit code:
Os votos dos candidatos serao exibidos a seguir:
('O candidato(a): ', 'CASSIO', 'tem: ', 50, 'votos.')
I would like it to be shown without the quotation marks and parentheses. I thank you.
EDIT: I was able to solve in a "grotesque" way, but it works. It follows code:
print'Candidato(a): '+aux['NOME']+' - '+str(aux['NUM_VOTOS'])+' votos\n'
Exit:
Candidato(a): CASSIO - 300 votos
Thank you very much!
– Cássio