zoukankan      html  css  js  c++  java
  • python 装饰器(语法糖)

    def  login(func):
        def testlogin():
            for  i in range(3):
                _username="abc"
                _passwrod="123456"
                user_status = False
                iuput = input("请输入账号:")
                input1 = input("请输入密码:")
                if iuput == _username and input1 == _passwrod:
                    user_status = True
                    func()
                    break
                else:
                    print("输入的账号或密码不正确请重新输入")
                    print("------------------------")
                    continue
            if user_status == False:
                print("超出输入限制,自动退出")
        return testlogin

    @login
    def moving():
        print("vip窗口---------------")
    def    putong():
        print("游客窗口----------------")
    @login
    def test():
        print("普通用户------------------")

        
    def test123():
        zidian = {1:"vip窗口",2:"游客窗口",3:"普通用户"}
        print(zidian)
        for i in range(10):
            input2 = int(input("请输入您选择的ID:::"))
            if input2 in zidian.keys():
                print(zidian[input2])
                if zidian[input2] == "vip窗口":
                    moving()
                    break
                if zidian[input2] == "普通用户":
                    test()
                    break
                if zidian[input2] == "游客窗口":
                    putong()
                    break
            print("输入有误,请重新输入")
            continue
    test123()

  • 相关阅读:
    01 Go 1.1 Release Notes
    Go 1 Release Notes
    go语言版本变化
    npm install的时候出现unexpected end of file错误提示时的解决办法
    Intellij IDEA注册激活破解
    vsCode如何从github拉取项目
    IDEA为了使用方便,需要改的几条配置
    IntelliJ IDEA 下的svn配置及使用
    intellij idea 的全局搜索快捷键方法
    Interllij IDEA中启动web项目
  • 原文地址:https://www.cnblogs.com/guanyf/p/8251410.html
Copyright © 2011-2022 走看看