首页 > 文档 > print()打印
2017
08-01

print()打印

Name print()打印
Examples String s = “The size is “;
int w = 1920;

int h = 1080;

print(s);

print(w, “x”, h);

// This program writes to the console:

// The size is 1920 x 1080

print()打印 - 第1张  | Processing编程艺术

print(“begin- “);

float f = 0.3;

int i = 1024;

print(“f is ” + f + ” and i is ” + 1024);

String s = ” -end”;

println(s);

// This program writes to the console:

// “begin- f is 0.3 and i is 1024 -end”

Description The print() function writes to the console area, the black rectangle at the bottom of the Processing environment. This function is often helpful for looking at the data a program is producing. The companion function println() works like print(), but creates a new line of text for each call to the function. More than one parameter can be passed into the function by separating them with commas. Alternatively, individual elements can be separated with quotes (“”) and joined with the addition operator (+).

Using print() on an object will output null, a memory location that may look like “@10be08,” or the result of the toString() method from the object that’s being printed. Advanced users who want more useful output when calling print() on their own classes can add a toString() method to the class that returns a String.

Note that the console is relatively slow. It works well for occasional messages, but does not support high-speed, real-time output (such as at 60 frames per second). It should also be noted, that a print() within a for loop can sometimes lock up the program, and cause the sketch to freeze.

print () 函数写入控制台区域, 即处理环境底部的黑色矩形。此函数通常有助于查看程序正在生成的数据。辅助函数 println () 像打印 () 一样工作, 但是为每个调用函数创建一个新的文本行。可以通过将多个参数与逗号隔开来传递到函数中。或者, 可以用引号 (“”) 分隔各个元素, 并与加法运算符 (+) 联接。

在对象上使用 print () 将输出 null, 该内存位置可能看起来像 “@10be08”, 或者是从正在打印的对象中生成 tostring () 方法的结果。如果高级用户在自己的类上调用 print () 时需要更有用的输出, 则可以向返回字符串的类中添加 tostring () 方法。

请注意, 控制台相对较慢。它对偶尔的消息很有效, 但不支持高速、real-time 的输出 (如每秒60)。还应该注意, for 循环中的打印 () 有时会锁定程序, 并导致草图冻结

Syntax print(what)
print(variables)
Parameters
what String, float, char, boolean, or byte: data to print to console
要打印到控制台的数据
variables Object[]: list of data, separated by commas
数据列表, 用逗号分隔
Returns void
Related println()
printArray()
join()


最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。