zoukankan      html  css  js  c++  java
  • 循环判断以及文件的使用--练习1

    #!/usr/bin/env python
    # -*- coding:utf-8 -*-
    # Author "Sniper"
    
    import getpass
    import os
    
    ### Registry Account   注册用户,将用户数据存入文件中
    
    print("Welcome to the Registry System!
    
    
    ")
    
    username = input("Please Input Your UserName:")
    password = input("Please Input Your Password:")
    password2 = input("Please Verify Your Password:")
    
    if password == password2 :
        userfile = open("username.txt", "w+", encoding="UTF-8")
        passfile = open("password.txt", "w+", encoding="UTF-8")
        userfile.write(username)
        passfile.write(password)
        userfile.flush()
        passfile.flush()
        userfile.seek(0)
        passfile.seek(0)
        userfile.close()
        passfile.close()
    else:
        print("Your Password Is Not Matched ,Check Your Input!")
        exit()
    
    cls = os.system("cls")
    
    ####Login System  登录用户,判断登录信息是否正确
    
    usr = open("username.txt")
    psd = open("password.txt")
    UserName = usr.read()
    PassWord = psd.read()
    
    count = 3
    while True :
        print("++++++++++++++++++++++++++++++++++++++")
        print("+++  Welcome To The Alauda System  +++")
        print("++++++++++++++++++++++++++++++++++++++")
        yourusername = input("Please input your username:")
        yourpassword = input("Please Input your password:")
        if UserName == yourusername and PassWord == yourpassword :
            print("Welcome {name} login ...".format(name=username))
            break
        else :
            print("Please input the true username or password !
    ")
            print("You lose 1 chance , Now you have {counts} chances
    ".format(counts=count -1))
        count -= 1
        if count == 0 :
            print("Uh-huh !!! You have been used up Your chances. Your account will be locked!!!
    ")
            exit()
    usr.close()
    psd.close()
  • 相关阅读:
    JavaScript——math对象
    JavaScript——日期相关
    JavaScript——数组与数组方法
    JavaScript——数值
    JavaScript——字符串方法
    关于CSS的一些问题(一)
    html5新增标签
    svg
    在自定义组件中使用v-model
    百度地图定位
  • 原文地址:https://www.cnblogs.com/Sniper-tech-share/p/9857829.html
Copyright © 2011-2022 走看看