安慰#

介绍#

所有控制台方法都将显示在 VEXcode AIR 控制台中。要查看控制台,必须连接控制台串行端口。控制台方法允许您在 VEXcode AIR 中实时显示文本、接收输入并格式化打印数据。

以下是与控制台交互的可用方法的列表:

操作 – 输出文本或清除控制台。

  • print – Displays text at the current cursor position.

  • clear_console – Clears all text from the Console.

Getter – 读取用户输入。

  • input – Returns the most recent user input as a string.

Mutator – 格式化打印文本。

行动#

print#

print displays text in the Console with the current set_console_text_color. Each use of print moves the cursor to the next line by default.

Usage:
print(value, end)

范围

描述

value

将作为字符串打印的文本。

end

Optional. The string added to the end of the printed text. Specified as end=. Default: end=“\n”, which is automatically hidden and moves the cursor to the next line.

# Display two messages consecutively
print("I'm printed on one line.")
print("I'm printed automatically on the next line!")

显示在打印控制台中连续显示的两条消息。

# Print three colors on one line in the Mission Logs
colors = ["Red", "Green", "Blue"]

for color in colors:
    print(color, end=", ")

显示在一行上依次打印三种颜色。

clear_console#

clear_console will clear all text from the Console.

Usage:
clear_console()

参数

描述

该方法没有参数。

# Clear a Console message after 2 seconds.
print("I will be cleared!")
wait(2, SECONDS)
clear_console()

吸气剂#

input#

input returns what is sent to the controller from the Console as a string.

Usage:
input()

参数

描述

该方法没有参数。

# Message the controller a name for it to greet
print("What is your name?")
answer = input()
print("Hi, " + answer + "! My name is AIR.")

当控制器向 VEX 打招呼时显示问候语,因为 VEX 是输入中使用的名称。

修改器#

set_console_text_color#

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
  • YELLOW

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

显示绿色文本消息。