• VEXcode Robotics Logo VEX Robotics Logo
  • VEX API Home Button VEX API Home Button
  • VEX 123 logo in purple VEX 123 logo in white
  • VEX GO logo in lime green VEX GO logo in white
  • VEXcode AIM logo in blue VEXcode AIM logo in white
  • VEX IQ logo in blue VEX IQ logo in white
  • VEX EXP logo in red VEX EXP logo in white
  • VEX V5 logo in red VEX V5 logo in white
  • VEX CTE logo in green VEX CTE logo in white
  • VEX AIR logo in orange VEX AIR logo in white
  • VEXcode VR logo in gold VEXcode VR logo in white
跳至主要内容
Ctrl+K

< Back to Platform Select

  • VEX EXP
  • 欢迎来到 VEX EXP 的 API 参考网站
  • Python
  • 打印控制台
简体中文
  • English
  • Spanish
  • VEXcode Robotics Logo

版块导航

  • 区块
  • 转变
  • Python
    • 枚举
    • 加速度计
    • 可寻址LED
    • 人工智能视觉
    • 模拟输入
    • 手臂
    • 脑
    • 保险杠
    • 颜色
    • 竞赛
    • 控制器
    • 数字输入
    • 数字输出
    • 距离
    • 传动系统
    • 电磁铁
    • 编码器
    • 事件
    • 陀螺仪
    • 惯性
    • 引领
    • 光
    • 限制
    • 线
    • 消息链接
    • 发动机
    • Motor29
    • 汽车集团
    • 摩托维克托
    • 物体探测器
    • 光学的
    • 气动
    • 电位器
    • 电位器V2
    • 打印控制台
    • 脉宽调制
    • 旋转
    • 串行链路
    • 伺服
    • 信号塔
    • 智能驾驶
    • 声纳
    • 线
    • Triport
    • 想象
  • C++

平台导航

  • VEX 123 logo in purple VEX 123 logo in white
  • VEX GO logo in lime green VEX GO logo in white
  • VEXcode AIM logo in blue VEXcode AIM logo in white
  • VEX IQ logo in blue VEX IQ logo in white
  • VEX EXP logo in red VEX EXP logo in white
  • VEX V5 logo in red VEX V5 logo in white
  • VEX CTE logo in green VEX CTE logo in white
  • VEX AIR logo in orange VEX AIR logo in white
  • VEXcode VR logo in gold VEXcode VR logo in white

打印控制台#

  • 命令

    • 打印到打印控制台

      • 格式

      • 新线

      • 不同的颜色

    • 清除打印控制台

打印控制台命令仅在使用 VEXcode EXP 时可用。如果您在 VS Code 中编码,则需要使用 brain.screen 命令打印到 V5 的 Brain Screen。

所有新项目都从打印控制台中的第 1 行光标开始。

命令#

Print to the Print Console#

The print(text, end) method prints text on the screen using the current cursor position.

参数

描述

文本

要打印到打印控制台的字符串。

结尾

是否跳至打印控制台的下一行。默认为空。

格式#

Values being printed to the Print Console can use the Python format method.

一些常用的格式类型是:

  • d - 十进制整数

  • f - 浮点数

  • o - 八进制整数

  • s - 字符串

In order to use a formatting type, put the desired formatting type in curly brackets ({}), starting with a colon (:) followed by .format.

此示例将打印数字 3.140000。

print("{:f}".format(3.14))

You can also include a number to specify how many decimal places you want to be printed. Do so by including a . and the number of decimal places before your formatting type.

此示例将打印数字 3.14。

print("{:.2f}".format(3.14))

You can also include sensors with the format method to change how many decimals are returned when the sensor’s value is reported.

print("{:.2f}".format(brain.timer.time(SECONDS)))

新线#

By default, Python will add a new line after each print command. To print multiple values to the same line, use the end parameter.

In this example, the text from both print commands will be printed on the same line.

print("This text will be ", end="")
print("printed on the same line")

不同的颜色#

您可以使用以下颜色代码更改打印到打印控制台时文本的颜色:

  • [31m - Red

  • [32m - Green

  • [34m - Blue

  • [30m - Black

  • [37m - White

  • [33m - Yellow

  • [91m - Orange

  • [35m - Purple

  • [36m - Cyan

  • [97m - Transparent

All color codes need to follow an escape sequence = \033 in order to function.

You can either use this directly in a print command with a string.

# Print VEXcode in Red to the Print Console.
print("\033[31mVEXcode")

Or, you can use it on its own to set all print commands afterwards to the set color.

# Set the Print Console text color to Red before printing VEXcode.
print("\033[31m")
print("VEXcode")

**返回:**无。

Clear the Print Console#

By using \033[2J inside of the print command, you can clear the entire Print Console. This will also set the cursor back to row 1.

下面的示例将打印“VEXcode”,然后在 2 秒后清除打印控制台。

print("VEXcode")
wait(2, SECONDS)
print("\033[2J")

上一页

电位器V2

下一页

脉宽调制

On this page
  • 命令
    • Print to the Print Console
      • Format
      • New Lines
      • Different Colors
    • Clear the Print Console
Innovation First, International

VEX 和 VEX Robotics 是 Innovation First, Inc. 的商标或服务标志 版权所有 ©2025。保留所有权利。VEX Robotics, Inc. 是 Innovation First International, Inc. 的子公司。所有其他产品名称/商标均为其各自所有者的财产。专利和/或正在申请的专利 - innovationfirst.com/patents
网站隐私政策 / 网站使用条款 / Cookie 政策 / 软件隐私政策

访问 VEX Robotics Facebook 页面 访问 VEX Robotics Twitter 页面 访问 VEX Robotics Instagram 页面 访问 VEX Robotics YouTube 页面
VEX API 反馈表

我们重视您的反馈!请使用此表单分享建议、赞美或报告 VEX API 的错误。您的反馈有助于我们完善 VEX API 文档。

如果您遇到技术问题或需要客户支持,请访问 support.vex.com.

  • Send Happy Feedback
  • Send Sad Feedback

注意:当前 URL 将与您的消息共享

通过添加您的电子邮件地址,您同意如果我们对您的反馈有疑问,VEX 可以向您发送电子邮件。
隐私政策 >
请提供您的反馈。 反馈提交成功!
Choose Which VEX IQ Generation to View

VEX IQ (1st gen)

VEX IQ (2nd gen)