Python#
本指南详细介绍了如何在 VEXcode VR 中使用 Python 方法。您将在此学习如何阅读和理解每个命令,包括其全面的描述、参数和使用示例。
了解方法条目#
API 参考文档中的每个方法条目都包含以下组件:
命令名称 – 该命令的正式名称。
描述 – 简要说明该命令的作用以及它可能返回的结果。
定义 – 命令的语法,展示如何在代码中编写该命令。
参数表 – 列出该命令接受的所有输入。
示例代码 – 提供一个可复制粘贴的代码块作为使用示例。
示例方法输入#
旋转#
rotation returns the current rotational value of a drivetrain as a float.
Usage:
drivetrain.rotation(units)
参数 |
描述 |
|---|---|
|
The unit used to represent the rotational value:
|
def main():
# Display the rotation after turning
drivetrain.turn_for(RIGHT, 450, DEGREES)
brain.print("Rotation: ")
brain.print(drivetrain.rotation(DEGREES))
# VR threads — Do not delete
vr_thread(main)