Roman_Sarnov

Untitled

Sep 21st, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. def privestvie():
  2. filename = 'polzovatel.json'
  3. try:
  4. with open(filename) as file:
  5. username = json.load(file)
  6. except FileNotFoundError:
  7. return None
  8. else:
  9. return username
  10.  
  11.  
  12. def sozdanie():
  13. filename = 'polzovatel.json'
  14. username = input('Введите ваше имя: ')
  15. with open(filename, 'w') as file:
  16. json.dump(username,file)
  17. return username
  18.  
  19.  
  20. def vivod():
  21. a = privestvie()
  22. if a:
  23. print('С возвращением, ' + a )
  24. else:
  25. a = sozdanie()
  26. print('Мы вас запомнили, ' + a)
  27. vivod()
Advertisement
Add Comment
Please, Sign In to add comment