51_work--模拟登陆

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了51_work--模拟登陆相关的知识,希望对你有一定的参考价值。

import sys
count=0
while count<3:
    user = input("Please enter user name:")

    lock_file = open(‘D:\\lock.txt‘, ‘r+‘)
    lock_list = lock_file.readlines()
    for lock_line in lock_list:
        lock_line = lock_line.strip(‘\n‘)
        if user == lock_line:
            print(‘The user has been locked‘)
            sys.exit()

    user_file = open("D:\\username.txt", ‘r‘)
    user_list = user_file.readlines()
    for user_line in user_list:
        name, pwd = user_line.strip(‘\n‘).split()
        if user == name:
            count_1 = 0
            while count_1 < 3:
                password = input(‘Please enter user password:‘)
                if password == pwd:
                    print(‘%s welcome!‘ % user)
                    sys.exit()
                else:
                    print(‘Password error‘)
                    count_1 += 1
            if count_1 == 3:
                print(‘The password has been entered many times. The user has been locked‘)
                lock_file.write(user)
                sys.exit()
        else:
            pass
    else:
        if count != 2:
            print(‘The username does not exist‘)
    count += 1
else:
    print(‘The username has been entered many times‘)
    sys.exit()

 

以上是关于51_work--模拟登陆的主要内容,如果未能解决你的问题,请参考以下文章

模拟登陆提交

简单爬虫模拟登陆phpmyadmin

Scrapy基础(十四)————知乎模拟登陆

Python爬虫(二十二)_selenium案例:模拟登陆豆瓣

Python爬虫(二十二)_selenium案例:模拟登陆豆瓣

selenium模拟登陆