Python小脚本1

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

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表示用户被锁

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30590361/viewspace-2138553/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30590361/viewspace-2138553/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值