Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. 知识库
  3. 二维积木
  4. 读取表格

读取表格

Scheduled Pinned Locked Moved 二维积木
1 Posts 1 Posters 956 Views
  • 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.
  • C Offline
    C Offline
    creaticodeteacher2-mail
    wrote on last edited by admin
    #1

     

    先修科目

    • 表格简介

     

    介绍

    读取表格类似于读取列表,不同的是,你要指定列名和行号。在接下来的示例中,我们将使用表格“学生”。这个表格有4列、3行。

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/20a6502b-dccc-4432-ae2c-72c0b154ce43.png" width="500" style="border-radius: 5px; border: 1px solid #29622d;">

     

    获取表格的行数

    你可以用积木“表格( )的行数”获取表格的行数。如果表格为空,该积木就报告0。

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/a80f5fd7-3fad-4131-ae8b-b5ea5ffa7f18.gif" width="647" style="border-radius: 5px; border: 1px solid #29622d;">

     

    读取项的值

    如果你知道要找的某一项的列名和行号,可以用这个积木读取其值。

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/62d8b433-2271-4c93-a4f6-5b8a134023d9.png" width="500" style="filter: drop-shadow(0.35rem 0.35rem 0.4rem rgba(0, 0, 0, 0.5));">

     

    参数

    • 行号:行号介于1与表格总行数之间。
    • 列名:列名不区分大小写。例如,“Name”和“name”都可以代表“NAME”这一列。

     

    示例

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/0f51ce77-82de-47e9-9cfb-3d09b8b7bfc3.gif" width="950" style="border-radius: 5px; border: 1px solid #29622d;">

     

    读取一整行

    有时你需要读取一行所有项的值。就可以用这个积木获取所有值并将其连接在一起。

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/6d0d163c-1496-44a7-9279-4f0a8dd64862.png" width="450" style="">

     

    参数

    • 行号:行号介于1与表格总行数之间。
    • 表格名称:从下拉菜单中选择表格名称。
    • 分隔符:用什么字符隔开这一行的不同列的值。

     

    示例

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c46c723e-3413-46e9-82e6-dec8f3f97ef7.gif" width="900" style="border-radius: 5px; border: 1px solid #29622d;">

     

    查找列中的某一项

    可以用这个积木查找列中的某一项:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/b0bb5402-7645-48fa-92c7-e9d1d3a2b863.png" width="500" style="">

     

    参数

    • 要查找的项:要查找的项的值。
    • 列名:从哪一列中查找。
    • 表格名称:从下拉菜单中选择表格名称。

     

    示例

    例如,我们可以在“姓名”这一列查找某一名学生,该积木会返回行号。如果不存在这一项,该积木就返回值-1。如果存在多个相同的项,就返回第一个的行号。

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/236a39ba-2df6-44b0-b600-37dd5a84ea68.gif" width="1000" style="border-radius: 5px; border: 1px solid #29622d;">

     

    查找列中包含某一部分的那一项

    有时你不想进行精确匹配。比如,你只知道某一项的一部分,而不是这一项的完整内容。就可以用这个积木查找包含某一部分的那一项:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/92ec148e-ad4b-4a7b-a24d-292513528e73.png" width="580" style="">

     

    参数

    • 要查找的项的一部分:你要找的那一项的部分内容。
    • 列名:从哪一列中查找。
    • 表格名称:从下拉菜单中选择表格名称。

     

    示例

    比如,我们知道某个学生姓“姜”,但不知道他的全名。我们就可以查找姓名包含“姜”的学生。这个积木将返回行号。如果没有姓名包含“姜”,这个积木就返回-1。

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/51419386-7419-4237-b185-ba7ee8ef7664.gif" width="1000" style="border-radius: 5px; border: 1px solid #29622d;">

     

    用另外一列查找某一列

    有时候你要用另一列查找某个表格。例如,你想知道学号为“101”的学生的身高。为了解决这个问题,就用这个积木:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/a46a85a4-730c-40f3-b06f-060ff8ddcbc1.png" width="750" style="">

     

    参数

    • 目标列:要查询的那一列,比如本例中的“身高”。
    • 表格名称:从下拉菜单中选择表格名称。
    • 检查列:要检查的那一列,比如本例中的“学号”。
    • 检查列的值:在检查列你要找的值,比如本例中的101。

     

    示例

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/91b45040-ae41-4f06-a154-bb9bb7eb44ac.gif" width="1000" style="border-radius: 5px; border: 1px solid #29622d;">

    1 Reply Last reply
    0

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode