| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- # -*- coding: UTF-8 -*-
- import sys
- user_info = {'name':'xdc', 'password':'123'}
- def auth_login(func):
- def wrapper(*args, **kwargs):
- inp_user = input('用户名:').strip()
- inp_pwd = input('密码:').strip()
- user = False
- if inp_user == user_info['name'] and inp_pwd == user_info['password']:
- user = user_info['name']
- if user:
- func(*args, **kwargs)
- else:
- print("用户名或密码错误")
- return wrapper
- def index():
- print('炫酷的主页')
- @auth_login
- def user_center():
- print('用户中心')
- def main():
- while 1:
- print("""
- 1、访问首页
- 2、访问用户中心
- 3、退出
- """)
- select = input('>>:')
- if select == '1':
- index()
- elif select == '2':
- user_center()
- elif select == '3':
- sys.exit()
- if __name__ == "__main__":
- main()
|