gorskaja2019

Untitled

May 8th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. from tkinter import Tk, simpledialog, messagebox, Canvas
  2.  
  3. root = Tk()
  4.  
  5. #считали данные
  6. results = {}
  7. file = open('records.txt','r',encoding='utf-8')
  8. for line in file:
  9. line = line.rstrip() #line = 'allena,10'
  10. people, score = line.split(',') # 'allena' '10'
  11. results[people] = score
  12. file.close()
  13.  
  14. score = 120
  15. i = 0
  16. while i < 3:
  17. people = simpledialog.askstring('Сохраним результат','Ваше имя?')
  18. if people in results:
  19. if int(results[people]) < score:
  20. results[people] = str(score)
  21. else:
  22. results[people] = str(score)
  23. file = open('records.txt','a',encoding='utf-8')
  24. file.write(people+','+str(score)+'\n')
  25. file.close()
  26. i += 1
Advertisement
Add Comment
Please, Sign In to add comment