#!/usr/bin/env python
db = {}
def newuser():
prompt = 'login desired: '
while True:
name = raw_input(prompt)
if db.has_key(name):
prompt = 'name taken, try anothern'
continue
else:
break
pwd = raw_input('passwd: ')
db[name] = pwd
def olduser():
name = raw_input('login: ')
pwd = raw_input('passwd: ')
passwd = db.get(name)
if passwd == pwd:
print 'welcome back', name
else:
print 'login incorrect'
def showmenu():
prompt = """
(N)ew User Login
(E)xisting User Login
(Q)uit
Enter choice:"""
done = False
while not done:
chosen = False
while not chosen:
try:
choice = raw_input(prompt).strip()[0].lower()
except:
choice = 'q'
print 'nYou picked: [%s]' % choice
if choice not in 'neq':
print 'invalid option, try again'
else:
chosen = True
if choice == 'q':done = True
if choice == 'n':newuser()
if choice == 'e':olduser()
if __name__ == '__main__':
showmenu()
[root@localhost src]# python usrpw.py (N)ew User Login (E)xisting User Login (Q)uit Enter choice:n You picked: [n] login desired: root passwd: 1 (N)ew User Login (E)xisting User Login (Q)uit Enter choice:n You picked: [n] login desired: root name taken, try another
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有