我试图在 swift 中使用 \t 显示时缩进数据,但它不起作用

I am trying to indent data when displaying using \t in swift but it isn't working

我正在尝试 print() 输出两个数组,而不是在每个数字之间用 \t(tab) 显示在一行中。
它显示在一列中,没有 \t .
不确定我做错了什么。

for j in 0 ..< dicePossibleNum.count
{
    print("\(dicePossibleNum[j])\t") //displays possible dice numbers
}


print("\n==================================================\n")

for i in 0 ..< diceResult.count
{
    print("\(diceResult[i])\t") // displays dice results
}

这是结果

2
3
4
5
6
7
8
9
10
11
12

============================================= =====

4
2
7
4
21
18
14
13
6
10
2

感谢您的帮助,
我是编程新手。

Swift 'print()' 函数默认附加一个换行符。尝试

print("Hello", terminator:"")

这使得 'print()' 在行尾添加一个空字符串,而不是换行符。你也可以试试:

print("Hello", terminator:"\t")

...这将在行尾添加一个制表符。

这是尝试此代码的简单方法..

 let dicePossibleNum : NSArray = ["1","2", "3","4","5","6", "7","8","9","10", "11","12",]
 let totalcount : Int = dicePossibleNum.count as Int

 for j in 0..<totalcount {
      print("Hello", dicePossibleNum[j],"\t")
 }

输出:

Hello 1     
Hello 2     
Hello 3     
Hello 4     
Hello 5     
Hello 6     
Hello 7     
Hello 8     
Hello 9     
Hello 10    
Hello 11    
Hello 12