资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

Python小脚本1-创新互联

#!/usr/bin/python
# -*- coding: UTF-8 -*-

成都创新互联公司公司2013年成立,是专业互联网技术服务公司,拥有项目网站建设、网站设计网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元民勤做网站,已为上家服务,为民勤各地企业和个人服务,联系电话:18980820575

def account_login(account):
    if account in Dict.keys():
        tmp=Dict[account]
        password=input("enter the password:")
        if password in tmp.keys():
           if tmp[password] == 0:
               return 0
           else:
               return 3
        else:
           print('Error password:')
           return 1
    else:
        return 2

def lock_account(account):
    for k in Dict:
        if k == account:
           for subk in Dict[k]:
                Dict[k][subk]=1

def try_times(account):
     num=3
     while num>0:
           result=account_login(account)
           if result == 1:
              num=num-1
              if num == 0:
                 lock_account(account)
                 print('The account %s is locked now!'%account)
                 exit()
           elif result == 2:
              print('no account')
              exit()
           elif result == 3:
              print('The account was locked')
              exit()
           elif result == 0:
              print('success login on the %s!'%account)
              break

list1 = []
list2 = []

def check_intnumber(n):
    if int(n) % 2 == 0:
        return True
    else:
        return False

def append_list(arg_list):
    global list1
    global list2
    for i in arg_list:
        if check_intnumber(i) == True:
            list1.append(i)
        elif check_intnumber(i) == False:
            list2.append(i)

def filit_number(arg):
    arg_list = arg.split(',')
    for i in arg_list:
        if str.isdigit(i) == False:
            arg_list.remove(i)
        else:
            pass
    return arg_list

def main():
    account=input("enter the accout:")
    try_times(account)
    arg = input('enter someting to check:')
    arg_list = filit_number(arg)
    append_list(arg_list)
    print('odd number',list2)
    print('even number',list1)

if __name__ == '__main__':
    Dict = {'oracle': {'a123': 0}, 'root': {'b123': 0}, 'mysql': {'c123': 1}}
    main()


## 新手小试牛刀,主要执行功能前需要用户验证,其中用户字典里面0表示正常 1表示用户被锁


网页标题:Python小脚本1-创新互联
当前路径:http://cdkjz.cn/article/cddhps.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220