zoukankan      html  css  js  c++  java
  • 作业练习

    #:/usr/bin/env python 
    # # -*- coding:utf-8 -*-
    usernames = ['xiaohei','xiaobai','xiaoming']
    passwords = ['123456','11111','1']
    #print(dict(zip(usernames,passwords)))
    
    user_info={}
    for i in range(len(usernames)):
         user_info[usernames[i]]=passwords[i]
    for i in range(3):
        user = input('请输入账号')
        pwd = input('请输入密码')
        again_pwd =input('请再次输入密码')
        if user in usernames:
            print('用户名已被注册')
        elif again_pwd != pwd:
            print('密码不一样')
        elif  user == ' 'or pwd == ' 'or again_pwd == ' ':
            print('用户名密码不能为空')
        if pwd ==again_pwd:
            print('注册成功')
        # user_info[user]=pwd
            user_info.setdefault(user,pwd)
            print(user_info)
        #continue
    print('次数超限')

    登录

    #:/usr/bin/env python
    # # -*- coding:utf-8 -*-
    usernames = ['xiaohei','xiaobai','xiaoming']
    passwords = ['123456','11111','1']
    #print(dict(zip(usernames,passwords)))
    user_info={}
    for i in range(len(usernames)):
         user_info[usernames[i]]=passwords[i]
    for i in range(3):
        user = input('请输入账号')
        pwd = input('请输入密码')
        if user =='' or ''.isspace():   #方法检测字符串是否只由空格组成
            print ('账号不能为空')
            continue
        elif pwd ==''or pwd.isspace():
            print('请重新输入')
            continue
        # else:
        #     print('请输入正确的账户')
        if user_info.get(user): #字典中查找的值
            if user_info[user] == pwd:
                print('登录成功')
                break
            else:
                print('密码错误')
                continue
        else:
            print('账号未注册')
  • 相关阅读:
    zoj 3593 One Person Game
    poj 2115 C Looooops
    hdu 1576 A/B
    hdu 2669 Romantic
    poj1006 Biorhythms
    中国剩余定理(孙子定理)
    Pseudoprime numbers---费马小定理
    青蛙的约会----POJ1061
    [POJ2942]:Knights of the Round Table(塔尖+二分图染色法)
    [BZOJ1718]:[Usaco2006 Jan] Redundant Paths 分离的路径(塔尖)
  • 原文地址:https://www.cnblogs.com/xxxxyanyan/p/12769075.html
Copyright © 2011-2022 走看看