zoukankan      html  css  js  c++  java
  • 变量与基本数据类型

    嵌套取值操作

    1. 请取出第一个学生的第一个爱好

    students_info = [['egon', 18, ['play', ]], ['alex', 18, ['play', 'sleep']]]
    print(students_info[0][2][0])

    2. 针对字典,请取出取公司名

    info = {
        'name': 'egon',
        'hobbies': ['play', 'sleep'],
        'company_info': {
            'name': 'Old boy',
            'type': 'education',
            'emp_num': 40,
        }
    }
    #  请取出取公司名:
    print(info['company_info']['name'])

    3. 针对下述类型,取第二个学生的第二个爱好

    students = [
        {'name': 'alex', 'age': 38, 'hobbies': ['play', 'sleep']},
        {'name': 'egon', 'age': 18, 'hobbies': ['read', 'sleep']},
        {'name': 'wupeiqi', 'age': 58, 'hobbies': ['music', 'read', 'sleep']},
    ]
    
    print(students[1]['hobbies'][1])

    附加题

    1. 输入账号密码完成验证,验证通过后输出"登录成功"

    while True:
        account = input('your account:')
        password = input('your password')
        if account == 'Avery':
            if password == '369':
                print('登陆成功')
                exit()
            else:
                print('密码输入错误,请重新输入')
                continue
        else:
            print('账号输入错误,请重新输入')

    2. 可以登录不同的用户

    account_dic = {
        'Avery': '369',
        'Kaia': '123'
    }
    while True:
        account = input('your account:')
        password = input('your password')
        if account in account_dic:
            if password == account_dic[account]:
                print('登陆成功')
                exit()
            else:
                print('密码输入错误,请重新输入')
                continue
        else:
            print('账号输入错误,请重新输入')
  • 相关阅读:
    编译器小知识
    C++ 文件大小格式化
    如何利用开盘半小时预测当天走势
    判断股票跌到位及买进时机的简单原则
    六招炒股绝技 牛市熊市都赚钱
    细分行业龙头
    股市新手入门口诀
    关于量价十八则的口诀
    如何确认底部的条件及操作原则
    每日一招:散户巧寻主力筹码的方法
  • 原文地址:https://www.cnblogs.com/avery-w/p/14192842.html
Copyright © 2011-2022 走看看