Advertisement
j7sx

Untitled

Feb 7th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.82 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import sqlite3 as db
  5.  
  6. #проверка на существующего пользователя и пароль
  7. print ('input reg for reg or enter your name')
  8. conn = db.connect('players.db')
  9. c = conn.cursor()
  10. _id = input('')
  11. if _id != 'reg' or 'REG':
  12.   player_ex = c.execute("SELECT login FROM users WHERE login=?", (_id,))
  13.   count = c.fetchone()
  14.   print (count)
  15.   while _id not in(count):
  16.     print ("имя не существует, выбери другое: ")
  17.     _id=input()
  18.   else:
  19.     print ('hello, ', _id)
  20.   c.execute("SELECT password FROM users WHERE users.login=?", (_id,))
  21.   expwd = c.fetchone()
  22.   password_exist=input('enter your password')
  23.   while password_exist not in (expwd):
  24.     print ("Password is incorrect. Please type again:")
  25.     password_exist=input('')
  26.   else:
  27.     print("welcome back!")  
  28.  
  29. если пользователь существует:
  30. [sava@sava-pc mypr]$ python main.py
  31. input reg for reg or enter your name
  32. sava
  33. ('sava',)
  34. hello sava
  35. enter your password
  36. Password is incorrect. Please type again:
  37. 123
  38. welcome back!
  39. [('sava', '123'), ('qwerty', '1'), (None, None)]
  40.  Чтобы узнать базовые характеристики персонажа
  41.  введи его название  на английском: warrior или archer, или wizard или stop,
  42.  чтобы перейти к выбору персонажа. Нажми ENTER ^Z
  43. [28]+  Stopped                 python main.py
  44.  
  45. если пользователь не существует:
  46. [sava@sava-pc mypr]$ python main.py
  47. input reg for reg or enter your name
  48. ert
  49. None
  50. Traceback (most recent call last):
  51.   File "main.py", line 15, in <module>
  52.     while _id not in(count):
  53. TypeError: argument of type 'NoneType' is not iterable
  54. [sava@sava-pc mypr]$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement