日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

Python之编写登录接口

發布時間:2023/12/20 python 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python之编写登录接口 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

編寫登陸接口

輸入用戶名密碼
認證成功后顯示歡迎信息
輸錯三次后鎖定

本文采用的文本在代碼中已詳細注釋,流程圖如下:
代碼如下:

#!/usr/bin/env python # Author:Zhu dongdong import os import sys #the article use file : ''' username_Password.txt: aaa 111 bbb 222 ccc 333 ddd 444 lock_username.txt: aaa ddd ''' user_name = "" password = "" count = 0#the count is used for cycle(while) count1 = 0#the count1 is used for judging #check username is lock or not def check_username_isLock():with open(r"E:/lock_username.txt")as file2:locklist = file2.readlines()for lock_name in locklist:username = lock_name.strip("\n")if username == user_name :print("the operation is too frequently")exit()return #return 1 represent that username is exist and return 0 against def check_username_isExist():x = 0with open(r"E:/userName_Password.txt")as file1:list = file1.readlines()for List_user_andName in list:(user, password1) = List_user_andName.strip("\n").split(" ")if user_name == user:x = 1return x #check the password is right def check_password_isok(count1):with open(r'E:/username_Password.txt')as file:list = file.readlines()for user in list:(username,passsword1) = user.strip("\n").split(" ")if user_name == username and password == passsword1:print("Welcome to login...")exit()elif user_name == username and password != passsword1:count1 = count1 + 1print("The input of password is error!")return count1 #write the username to 'lockfile' def write_lockusername():file = open("E:lock_username.txt", "a")file.write('''\n{a}'''.format(a = user_name))return while count == 0:user_name = input("please input the username:")check_username_isLock()ret = check_username_isExist()if ret == 1:#represent username is existpassword = input("Please input the password:")breakelse :print("The username is error,Please try again.") while count == 0:count1 = check_password_isok(count1)if count1 == 3:write_lockusername()exit(0)password = input("Please input the password:")

總結

以上是生活随笔為你收集整理的Python之编写登录接口的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。