python用户界面_Python小作业一(用户登录交互界面)

一、作业

要求:1、要有一个类似登录操作系统的用户登录的交互。

2、判断用户是否存在。

3、输入三次密码错误后,退出。

二、流程图

按照作业要求流程图如下:

wKioL1fGWpjCssuUAAClclVTJPg599.png-wh_500x0-wm_3-wmp_4-s_2570541130.png

Python脚本如下:1 #!/usr/bin/env python

2

3

4 import sys

5

6 user=["liyuanchuan","zhanggang","gaolixu"]

7

8 passwd={'liyuanchuan':'yuanchuan','zhanggang':'zhanggang','liangqing':'liangqing'}

9

10

11

12 count=1

13 while True:

14 A=raw_input('login:').strip()

15 if A in user:

16 while count <= 3:

17 B=raw_input('passwd:').strip()

18 if B == passwd[A]:

19 print "welcome to python world"

20 sys.exit()

21 else:

22 if count == 3:

23 print "your username is locked,thank you,goodbay!"

24 sys.exit()

25 print "your passwd incorrect,you have only remain %s,please input again" %(3-count)

26 count=count+1

27 continue

28 else:

29 print "your username is not exits,please input again"

30 continue

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值