• 作业.


    注册

    def register():
        registor_count = 0
    
        while registor_count < 3:
            username_inp = input('输入用户名:')
            userpwd_inp = input('输入密码:')
            re_userpwd_inp = input('再次输入密码:')
            if userpwd_inp == re_userpwd_inp:
                with open('user_info.txt','a',encoding = 'utf8') as fa:
                    fa.write(f'{username_inp}:{userpwd_inp}
    ')
                print('注册成功')
                break
            else:
                registor_count += 1
                print('密码不同')
                continue
    

    登录

    def login():
        username_inp = input('输入用户名:')
        userpwd_inp = input('输入密码:')
    
        with open('user_info.txt','r',encoding='utf8') as fr:
            for user_info in fr:
                user_name,user_pwd =user_info.split(':')
                if (user_name.strip() == username_inp and user_pwd.strip() == userpwd_inp):
                    print('登录成功')
                    break
            else:
                print('登录失败')
    

    猜年龄

    def guess_age():
        age = 18
        guess_count = 0
        while guess_count < 3:
            guess_age = int(input('你猜的年龄:'))
            guess_count += 1
            if guess_age > age:
                print('猜大了')
            elif guess_age < age:
                print('猜小了')
            else:
                print('猜对了')
                break
        else:
            print('呵呵 牛逼 牛逼')
    

    选择奖品

    def prize():
        prize_dict = {
            '1':'奖品1',
            '2':'奖品2',
            '3':'奖品3',
            '4':'奖品4'
        }
        print(prize_dict)
        prize_choice = input('选择一个奖品:')
        if prize_choice in prize_dict:
            print(f"你选择了一个{prize_dict.get(prize_choice)}")
        else:
            print('没有该商品')
    
    
    
    def menu():
        register()
        login()
        guess_age()
        prize()
    
    
    menu()
    
  • 相关阅读:
    使用jackson美化输出json/xml
    mybatis不报错,但是查询结果为0
    @Valid基于hibernate
    spring 整合 mybatis (不含物理分页)
    mybatis insert 自动生成key
    mybatis 配置延迟加载 和 缓存
    mybaits foreach
    2015-08-13T17:39:15
    Introduction
    mybatis 存储过程调用
  • 原文地址:https://www.cnblogs.com/gfhh/p/11551254.html
Copyright © 2020-2023  润新知