Name |
str()字符串转换 |
Examples |
boolean b = false; byte y = -28; char c = ‘R’; float f = -32.6; int i = 1024;
String sb = str(b); String sy = str(y); String sc = str(c); String sf = str(f); String si = str(i);
sb = sb + sy + sc + sf + si;
println(sb); // Prints ‘false-28R-32.61024’ |
Description |
Converts any value of a primitive data type (boolean, byte, char, color, double, float, int, or long) to its String representation. For example, converting an integer with str(3) will return the String value of “3”, converting a float with str(-12.6) will return “-12.6”, and converting a boolean with str(true) will return “true”. When an array of values is passed in, then a String array of the same length is returned. 将基元数据类型的任何值 (布尔、字节、char、颜色、双精度、浮点型、int 或 long) 转换为其字符串表示形式。例如, 将一个整数转换为 str (3) 将返回 “3” 的字符串值, 将带有 str (-12.6) 的浮点转换为 “-12.6”, 并将布尔型转换为 str (true) 将返回 “true”。
在传入值数组时, 返回相同长度的字符串数组。 |
- 本文固定链接: http://iprocessing.cn/2017/07/20/str字符串转换/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表