python模拟登录

python 复制代码
i=0
while i<3:
    user_name=input("Enter your name:")
    pwd=input('Enter your password:')
    if user_name=='******' and pwd=='*****':
        print('Welcome',user_name,' to the system')
        i=8
    else:
        if i<2:
            print('Wrong username or password,you have ',2-i,'chances left')
        i+=1
if i==3:
    print('You have entered wrong username or password three times,you have been locked')        

登录成功的情况:

登录失败的情况:

相关推荐
数据与后端架构提升之路3 分钟前
TeleTron 源码揭秘:如何用适配器模式“无缝魔改” Megatron-Core?
人工智能·python·适配器模式
hele_two1 小时前
快速幂算法
c++·python·算法
l1t2 小时前
利用DeepSeek将python DLX求解数独程序格式化并改成3.x版本
开发语言·python·算法·数独
Cemtery1164 小时前
Day26 常见的降维算法
人工智能·python·算法·机器学习
星空椰4 小时前
快速掌握FastAPI:高效构建Web API
python·fastapi
塔尖尖儿4 小时前
Python中range()到底是什么演示
python
Ethan-D5 小时前
#每日一题19 回溯 + 全排列思想
java·开发语言·python·算法·leetcode
weixin_446934036 小时前
统计学中“in sample test”与“out of sample”有何区别?
人工智能·python·深度学习·机器学习·计算机视觉
weixin_462446237 小时前
使用 Python 测试 Mermaid 与 Graphviz 图表生成(支持中文)
python·mermaid·graphviz