usernames = ['cwl','pn','gxn','hyp']
passwords = ['123456','abc123','324234','23423']
#pn
#sdfsdf

#需要校验 用户不存在的话 要提示
#需要校验是否为空
#账号密码正确登录成功

#最多输错3次
#1、输入账号密码
#2、校验是否输入为空
#3、校验账号是否存在 list.count()
#4、从usernames里面找到user的下标,然后去password种去对应的密码
import datetime
today = datetime.datetime.today()
count = 0
# for i in range(4):
while count<3:
count+=1
username = input('username:').strip()#去掉一个字符串两边的空格
password = input('password:').strip()
if username=='' or password=='':
print('账号/密码不能空!')
# elif usernames.count(username)==0: #判断元素的个数
elif username not in usernames: #判断元素是否存在某个list里面
print('用户不存在!')
else:
user_index = usernames.index(username)#登录用户的下标
p = passwords[user_index]#根据下标取到密码
if password == p:#判断密码是否正确
print('欢迎%s登录,今天的日期是%s.'%(username,today))
break
else:
print('密码错误!')
else:
print('错误次数已经用尽')

count = 0
# for i in range(4):
while count<3:
count+=1
username = input('username:').strip()#去掉一个字符串两边的空格
password = input('password:').strip()
if username=='' or password=='':
print('账号/密码不能空!')
elif username=='niuhanyang' and password=='123456':
print('登录成功!')
else:
print('账号/密码错误!')
else:
print('错误次数已经用尽')

随机推荐

  1. 爬坑之路---Google map

    google.maps.event.adddDomListen(window, 'load', callback);当文档流中所有的dom加载完成后,执行回调函数,可以不用在script中使用defe ...

  2. 报错:keep must be either "first", "last" or False

    data_mac_set = data_mac.drop_duplicates(['std_mac']) 此时会报错:keep must be either "first", &q ...

  3. 【云短信】腾讯&阿里

    腾讯 : https://github.com/qcloudsms/qcloudsms_csharp 安装nuget包: using qcloudsms_csharp; using System.Co ...

  4. 牛客 黑龙江大学程序设计竞赛重现 19-4-25 D

    题意: n项工作 1~n  工时s[i] ~e[i], 工时有覆盖的工作不能被同一台机器同时操作, 问完成所有工作的最少机器数 思路:前缀差分和 e.g. a            2 3 4    ...

  5. 关于spark中DatatFrame函数操作中isin方法的使用

    需求: 1.需要从一张mysql数据表中获取并筛选数据 2.通过spark将该表读进来,形成一个df:DataFrame,有一个集合 val list = List[String]("小李& ...

  6. pycharm配置可视化数据库

    出于数据库安全性,数据库管理员会给数据库配置SSH,也就是为数据库增加一个安全协议(通信加密),加大外部用户对该数据库远程连接的难度. 利用SSH通道来连接远程数据库时需要以下信息:远程数据库服务器I ...

  7. python--网络编程requests

    一.requests 之前使用python自带的urllib模块去请求一个网站或者接口,但是urllib模块太麻烦了,传参数的话,都得是bytes类型,返回数据也是bytes类型,还得解码,想把返回结 ...

  8. spark mllib prefixspan demo

    ./bin/spark-submit ~/src_test/prefix_span_test.py source code: import os import sys from pyspark.mll ...

  9. pip更新

    python -m ** install -U **

  10. Spring Boot:如何优雅的使用 Mybatis

    mybatis-spring-boot-starter 官方说明:MyBatis Spring-Boot-Starter will help you use MyBatis with Spring B ...