安慰#

介绍#

IQ(第二代)控制台会显示在“监视”窗口中,并显示项目的文本输出。在其他环境(例如 VS Code)中,“print”命令会在终端上显示文本。新项目从光标位于第 1 行开始。

以下是所有可用方法的列表:

方法 – 与打印控制台交互。

打印#

print 使用当前光标位置在控制台中打印文本。

用法:
print(string, end)

参数

描述

细绳

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

结尾

可选。添加到打印文本末尾的字符串。指定为 end=。默认值:end="\n",表示自动隐藏并将光标移动到下一行。

# 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 Print Console
colors = ["Red", "Green", "Blue"]

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

清除打印控制台#

print 命令中使用 \033[2J,可以清除整个打印控制台。这也会将光标设置回第 1 行。

# Print to the console, then clear it after
# 2 seconds
print("VEXcode")
wait(2, SECONDS)
print("\033[2J")