Navigation

    喵了个咪乎

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Python学习

    学习打卡区
    1
    1
    9
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 叶
      叶茂森 last edited by

      1a6b8c6e-59ec-4eb5-a73b-8793189bbd44-image.png if语句
      if (条件):
      语句
      注意缩进和冒号
      python的相等检查区分大小写
      !同样表示 不

      检查特定值是否在列表中

      elif
      相当于else if

      可以用if来判断列表是否为空

      5d9929a3-d5ad-446d-8998-ab5f83e637eb-image.png
      字典
      在python中,字典是对一系列的 键-值 对,使用花括号{}。

      基本格式:
      字典名={ "键" : "值", 键":"值" }
      用冒号连接键和值之间的关系。
      在需要时
      字典名[ "键" ] 来寻找对应的值

      添加键-值 对

      修改键-值 对同理

      删除键-值 对
      使用del 字典中的值来删除
      ps:print alien_0 可以查询该字典中存在的键-值 对

      字典特有一个方法 items()
      可以用于返回可遍历的键-值对
      使用时要注意没对的键-值对数据类型应当相同,否则报错

      1 Reply Last reply Reply Quote 0
      • First post
        Last post