设为首页 加入收藏

TOP

program 1 : python codes for login program(登录程序python代码)
2017-09-30 13:31:38 】 浏览:10037
Tags:program python codes for login 登录 程序 代码
#improt time module for count down puase time
import time
#set var for loop counting
counter=1
#login setting
while counter<=3:
        
    print('please enter username: ')
    username=input()
    print('please enter password: ')
    password=input()
    #dict for username and password
    userinf={
        'xiaoweilai':'xiaoweilai',
        'python':'123',
        'education':'edu123'
    }
    #different entering cases
    if userinf.__contains__(username) and userinf.get(username)==password:
        print('welcome to python world')
        break
    else:
        print("username/password's error","please try again")
        counter=counter+1
        #error entering for 3 times and forcely stop 10senconds.
        if counter==3:
            print('You try it too much times.')
            counter = 0
            while counter <= 10:
                print(10 - counter)
                time.sleep(1)
                counter = counter + 1
            counter=0
        continue

Read me 程序说明:

设计一个需要用户名和密码的登录程序

用户输入登录用户名和密码,后台处理用户输入的用户名和密码,即检测已有用户名和列表中有无该用户名和对应的密码是否错误。如果输入错误,继续尝试第二次,若第二次错误,继续尝试第三次,如果第三次输入错误则提示输入次数太多,并暂停输入10秒,显示10秒倒计时。倒计时结束后,继续尝试。不断循环,直至输入正确的用户名和密码。程序结束。

summary 知识点总结:

time 模块应用,字典应用,while 循环嵌套语句,break 和 continue 语句,if else 语句。

If you like, contact me. QQ 278857042  please note: python or big data.   

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Testlink接口使用方法-python语.. 下一篇第一周 day2 python学习笔记

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目