我需要转换数组 int
s 到字符串。按照代码执行此操作,但结果我收到了不需要的符号 [
]
import std.stdio;
import std.conv;
void main()
{
int [] x = [1,3,4,6];
string s = to!string(x);
writeln(s);
}
输出:
[1, 3, 4, 6]
如何使用 replace
在不破解的情况下删除括号?
最佳答案
例如,您可以这样做:
import std.stdio;
import std.conv;
import std.algorithm;
void main()
{
int [] x = [1,3,4,6];
writeln(x.map!(to!string).joiner(", "));
}
关于arrays - 如何将整数数组转换为字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36581856/