Python#

本网站提供 VEXcode AIM 中所有 Python 命令的详细参考。每个命令条目都包含描述、参数和使用示例,以帮助您了解如何有效地使用它们。

命令类别#

VEXcode AIM 中的 Python 命令按其功能分组。了解这些类别有助于有效地使用它们。

方法类型

描述

例子

行动

执行记录、打印或移动等操作。

robot.move_at moves the AIM Robot continuously at the specified angle until a new movement method is called or the project is stopped.

修改器

更新对象属性。

robot.set_move_velocity assigns the move velocity of the robot with the new set value.

吸气剂

用于返回数据。

controller.button_up.pressing checks if the up button is being pressed.

特性

与对象关联的属性。不是方法。

centerx is a property of the tuple returned by the AI Vision snapshot, returning an integer value of the object’s center X coordinate from 0 to 240.

回调

存储并稍后调用函数,通常由事件触发。

controller.button_up.pressed registers a function to be called when the Up button is pressed.

读取命令条目#

每个命令条目遵循一致的结构:

  • 命令名称——命令的正式名称。

  • 描述 – 对命令的作用和可能返回的内容的简要说明。

  • 定义——命令的语法,显示如何在代码中编写它。

  • 参数表 – 列出命令接受的所有输入。

  • 示例代码 – 格式化为代码块的使用示例。

命令输入示例#

设置控制台文本颜色#

set_console_text_color sets the color of all subsequent print commands.

Usage:
set_console_text_color(color)

范围

描述

color

The color to set:
BLACK, BLUE, CYAN, GREEN, ORANGE, PURPLE, RED, TRANSPARENT, WHITE, or YELLOW.

# Display a green message on the Console
set_console_text_color(GREEN)
print("I am green!")