怎么使用python实现不用装饰器制作登录器小程序

  介绍

这篇文章主要介绍怎么使用python实现不用装饰器制作登录器小程序,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

下面代码演示了不使用装饰器制作用户登录功能的小程序,在python3。x下可正常运行

# !/usr/bin/env  python3   #,- *安康;编码:utf-8  - * -   “““   Created 提醒Tue  Nov  26 15:26:58  2019      @author:根   “““      def 菜单():   打印才能(& # 39;选择# 39;.center (50 & # 39; & # 39;))   时间=msg 才能;& # 39;& # 39;& # 39;   1只才能回家   ,2只;金融   书,3只   4只;才能退出   & # 39;才能& # 39;& # 39;   打印(味精)才能   打印才能(““.center (50 & # 39; & # 39;))   ,   def 登录(login_flat,选择):   if 才能;not  login_flat:   ,,,while 正确的:   ,,,,,username =, str(输入(“用户名:“))   ,,,,,password =, str(输入(“密码:“))   ,,,,,if  choice ==, & # 39; 1 & # 39;   ,,,,,,,回家()   ,,,,,,,with 开放(& # 39;jingdong.txt& # 39; & # 39; " # 39;), as  f1:   ,,,,,,,,,for  line  f1:拷贝   ,,,,,,,,,,,element =, line.split (“,“, 1)   ,,,,,,,,,,,印刷(元素[0])   ,,,,,,,,,,,印刷(元素[1])   ,,,,,,,,,,,if  username.strip(),==,元素[0].strip(),以及password.strip(),==,元素[1].strip ():   ,,,,,,,,,,,,,印刷(“log 拷贝成功!“)   ,,,,,,,,,,,,,return 真实的   ,,,,,,,,,,,印刷(“failed 用log  !, try  it  !“)   ,,,,,elif  choice ==, & # 39; 2 & # 39;:   ,,,,,,,金融()   ,,,,,,,with 开放(& # 39;weixin.txt& # 39; & # 39; " # 39;), as  f2:   ,,,,,,,,,for  line  f1:拷贝   ,,,,,,,,,,,element =, line.split (“,“, 1)   ,,,,,,,,,,,if  username.strip(),==,元素[0].strip(),以及password.strip(),==,元素[1].strip ():   ,,,,,,,,,,,,,印刷(“log 拷贝成功!“)   ,,,,,,,,,,,,,return 真实的   ,,,,,,,,,,,印刷(“failed 用log  !, try  it  !“),,,   ,,,,,elif  choice ==, & # 39; 3 & # 39;:   ,,,,,,,的书()   ,,,,,,,with 开放(& # 39;jingdong.txt& # 39; & # 39; " # 39;), as  f3:   ,,,,,,,,,for  line 拷贝f3:   ,,,,,,,,,,,element =, line.split (“,“, 1)   ,,,,,,,,,,,if  username.strip(),==,元素[0].strip(),以及password.strip(),==,元素[1].strip ():   ,,,,,,,,,,,,,印刷(“log 拷贝成功!“)   ,,,,,,,,,,,,,return 真实的   ,,,,,,,,,,,印刷(“failed 用log  !, try  it  !“),,,,,,,,,,,,,,   其他的才能:   ,,,print(“你have  logged 拷贝!“)   ,,,return 真实的   # @login (login_flat,选择),,,,,,,,,,,,   def 家居():   打印才能(“家庭.....“)   # @login (login_flat,选择),   def 金融():   打印才能(“财政.....“)   # @login (login_flat,选择),   def 书():   打印才能(“书.....“)      ,,   login_flag =False   while 真正的:   菜单()才能   choice =,才能输入(“your 选择:“)   null   null   null   null   null   null   null   null   null   null   null

怎么使用python实现不用装饰器制作登录器小程序