快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

Python小脚本1

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

创新互联公司专业成都网站建设、网站设计,集网站策划、网站设计、网站制作于一体,网站seo、网站优化、网站营销、软文发稿等专业人才根据搜索规律编程设计,让网站在运行后,在搜索中有好的表现,专业设计制作为您带来效益的网站!让网站建设为您创造效益。

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://6mz.cn/article/jsjesp.html

其他资讯