返回顶部

收藏

python编写登录接口

更多
#!/usr/bin/env python
# -*- coding:utf-8 -*-

import getpass

logintimes = 0
while logintimes < 3:
    name=raw_input("Please input your username:")
    pwd=getpass.getpass("Please input your password:")
    if name=='wxy' and pwd=='123':
        #正确后允许进入并退出循环
        print "Welcome,login succeed!"
        break
    else:
        #错误时,出错计数加1
        print "Error,login again:"
        logintimes+=1
else:
    #错误达到三次后,结束此循环
    print "Sorry,account has been locked!"

标签:python

收藏

0人收藏

支持

0

反对

0

发表评论