?? new_login_user.py
字號:
#!/usr/bin/env python
import sys
db={}
def newuser():
prompt='name: '
while True:
name=raw_input(prompt)
if db.has_key(name):
prompt='name taken ,try another'
continue
else:
break
pwd=raw_input('password: ')
db[name]=pwd
def userload():
prompt='welcome to load in\n'
promptn='Enter name:'
promptp='Enter password'
valid=False
count=3
while count>0:
user_name=raw_input(promptn)
user_pwd=raw_input(promptp)
if (user_name,user_pwd) in db.iteritems():
print prompt,
break
if not valid:
print"warning-->the name and the password are wrong you have three chance to login"
w_o_n=raw_input('whether to continue : (y|n)' )
if w_o_n=='n':
break
count-=1
continue
else:
break
def showmenu():
prompt="""
(N)ew user login
(E)xiting user login
(Q)uit
Enter your choice:"""
done=False
while not done:
chosen=False
while not chosen:
try:
choice=raw_input(prompt).strip()[0].lower()
except (EOFError,KeyboardInterrupt,IndexError):
choice='q'
print'\n you picked:[%s]' % choice
if choice not in 'neq':
print'invaild option ,try again'
else:
chosen=True
if choice=='q': done=True
if choice=='n': newuser()
if choice=='e': userload()
if __name__=='__main__':
showmenu()
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -