国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > Python > 正文

Python實(shí)現(xiàn)簡(jiǎn)單登錄驗(yàn)證

2019-11-25 16:50:41
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

本文實(shí)例為大家分享了簡(jiǎn)單的Python登錄驗(yàn)證,供大家參考,具體內(nèi)容如下

編寫登錄接口

要求:1、輸入用戶名密碼

   2、認(rèn)證成功后顯示歡迎信息

   3、輸錯(cuò)三次后鎖定

#coding=utf-8__author__ = 'wangwc'import sys,oscount = 0locked = 0mark_user = 0mark_passwd = 0#獲取路徑def cur_file_dir():  path = sys.path[0]  if os.path.isdir(path):    return path  elif os.path.isfile(path):    return os.path.dirname(path)#print (cur_file_dir())path = cur_file_dir()#print(path)path1 = path.replace("http://",'/') + '/'#print (path1)#path2 = path1 + '/'#循環(huán)輸入while count < 3:  name = input("Username:").strip()  if len(name) == 0:    print ("Username can not be empty....")    continue  key = input("Password:").strip()  if len(key) == 0:    print("The password can not be empty!Try again...")    continue  f = open(path1 + "username.txt","r")  userlist = f.readlines()  for user in userlist:    if user.strip() == name:      mark_user = 1  f.close()  if mark_user == 1:    f = open(path1 + "%s_lock.txt" %(name),"r")    locked = int(f.readline().strip())    f.close()  else:    print ("Username or Passsord wrong....")    break  if locked == 1:    print("Sorry, the username had been locked!!!Please call the system administrator...")  else:    f = open (path1 + "%s_passwd.txt" %(name),"r")    passwd = (f.readline().strip())    if passwd.strip() == key:      mark_passwd = 1    if mark_user == 1 and mark_passwd == 1:      f = open("%s_count.txt" %(name),"w")      f.write("0")      f.close()      print("%s,welcome BABY!" %(name) )      #input('Press Enter to exit')    else:      f = open("%s_count.txt" %(name),"r")      count = int((f.read().strip()))      f.close()      count +=1      f = open("%s_count.txt" %(name),"w")      f.write(str(count))      f.close()      print ("Username or password wrong!And the username '%s' has %d more chances to retry!" %(name,3 - count))      if(count == 3):        print ("'%s' has been locked!!!" %(name))        if os.path.exists(path1 + "%s_lock.txt" %(name)):          fobj = open(path1 + "%s_lock.txt" %(name),"w")          fobj.writelines("1/n")        else:          print ("Username or password wrong!")      continue

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 甘泉县| 南溪县| 红原县| 惠安县| 都昌县| 太保市| 永安市| 遂平县| 汉寿县| 泰宁县| 芜湖市| 鄄城县| 托里县| 徐州市| 南涧| 奉节县| 五台县| 平江县| 宜君县| 巴青县| 巫溪县| 黄骅市| 河津市| 科技| 广州市| 剑河县| 平远县| 石楼县| 离岛区| 蓬溪县| 无锡市| 扬州市| 通州区| 陇川县| 抚顺市| 溧阳市| 达孜县| 英德市| 科技| 渝北区| 长白|