#coding=utf-8 import sys user = {'user':'jshand', 'pass':'123' } userName = None #登录系统 def login(): userName = raw_input("login user:\n") if user['user'] == userName: checkpassword() else: print 'user is error!' login() #验证密码 def checkpassword(): password = raw_input("login password:\n") if user['pass'] == password: logon() else: print 'password is error!' checkpassword() #登录成功后进入查询 def logon(): print 'hello %s' % userName query() dict = { 'tt' :'她是一个麻醉医生(*^__^*) 嘻嘻……', 'jinshan' :'他是干it的O(∩_∩)O哈哈~', 'mama' :'家庭主妇~~~~(>_<)~~~~', } #查询系统 输入key 显示查询内容 def query(): queryKey = raw_input("Pleas input Your key\n") if queryKey =='exit' or queryKey =='quite': print 'Exit Success ,Bye!' sys.exit() if queryKey in dict.keys(): print 'Query thing is %s' %(dict[queryKey]) query() else: print 'Query Key is not exists for key %s' %(queryKey) query() #启动系统..... login()
python 入门(2)字典的使用,伪查询系统
猜你喜欢
转载自314649444.iteye.com/blog/2268647
今日推荐
周排行