python3下载手机安卓版,python下载手机版最新

大家好,小编在这里要分享,python3下载手机安卓版 python下载手机版最新,让我们开始吧!

#需求

编写登陆接口

- 输入用户名密码

- 输错三次后锁定账户

- 认证成功后显示欢迎信息

#脚本目录[root@localhost opt]# tree

.

├── 

├── 

└── 

0 directories, 3 files

#脚本文件#!/usr/bin/env python

#_*_ coding:utf-8 _*_

import sys

retry_limit = 3

retry_count = 0

account_file = ''

lock_file = ''

#三次验证循环

while retry_count 

#让用户输入用户名

username = raw_input('\033[31m Username: \033[0m')

lock_check = file(lock_file)

for line in lock_check.readlines():

if username in line:

()

#让用户输入密码

password = raw_input('\033[31m Password: \033[0m')

#获得account文件的用户和密码

f = file(account_file,'rb')

match_flag = False

for line in f.readlines():

user,passwd = line.strip('\n').split()

#对用户输入的用户密码进行匹配验证

if username == user and password == passwd:

print 'Match!', username

match_flag = True

break

f.close()

#判断有没有匹配成功,不成功则进行下一次循环,成功则输入欢迎信息

if match_flag == False:

print 'User unmatched'

retry_count += 1

else:

print "Welcome login wsyht Lerning system!"

()

else:

#三次循环完后开始锁账户

print 'Your account is locked!'

f = file(lock_file,'ab')

f.write(username)

f.close()

#查看账户文件[root@localhost opt]# cat 

wsyht wsyht

#查看锁文件[root@localhost opt]# cat 

[root@localhost opt]#

#执行脚本不匹配显示[root@localhost opt]# python 

Username: jenkins

Password: jenkins

User unmatched

Username: jenkins

Password: jenkins

User unmatched

Username: jenkins

Password: jenkins

User unmatched

Your account is locked!

#查看锁文件[root@localhost opt]# cat 

jenkins[root@localhost opt]#

#执行脚本匹配显示[root@localhost opt]# python 

Username: wsyht

Password: wsyht

Match! wsyht

Welcome login wsyht Lerning system


原文地址1:https://blog.csdn.net/weixin_39622150/article/details/110751217
参考资料:python中用turtle画一个圆形 https://blog.csdn.net/SXIAOYAN_/article/details/140061099

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值