我使用下面的代码
print("List:\n 1 \t Apple\n 2 \t Bananas\n 6 \t Oranges", terminator: "")
生成一个列表,以每个数字开始一个新行
然而它只是打印"列表:\ n 1 Apple \ n 2 Bananas \ n 6 Oranges"
在swift 1.2中它运行良好,但在Swift 2.0中,它只是不会识别" \ n",有人知道如何将字符串吐出不同的行吗?或什么取代了swift 2.0中的\ n?我知道这是基本的,但如果我不能跨行分割字符串,那么这个小问题将来会引起问题
提前致谢:)
答案 0 :(得分:1)
If you're using an Xcode Playground, what you see besides your code is the live panel where values are shown when possible. In your case it will show the argument that was passed to print
, which is the literal string. This is not the same as the console output, which will print the formatted string.
In Xcode 7 Playgrounds the console output can be found in:
Menu View > Debug Area > Activate Console
Note: this was previously in "Assistant Editor" in Xcode 6's Playgrounds.