Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import Tk, simpledialog, messagebox, Canvas
- root = Tk()
- #считали данные
- results = {}
- file = open('records.txt','r',encoding='utf-8')
- for line in file:
- line = line.rstrip() #line = 'allena,10'
- people, score = line.split(',') # 'allena' '10'
- results[people] = score
- file.close()
- score = 120
- i = 0
- while i < 3:
- people = simpledialog.askstring('Сохраним результат','Ваше имя?')
- if people in results:
- if int(results[people]) < score:
- results[people] = str(score)
- else:
- results[people] = str(score)
- file = open('records.txt','a',encoding='utf-8')
- file.write(people+','+str(score)+'\n')
- file.close()
- i += 1
Advertisement
Add Comment
Please, Sign In to add comment