字符转义

基本类型 / 字符串

// \t 插入制表符。
// \n 插入换行符。
// \r 插入回车符。
// \' 或 ' 插入单引号。
// \" 插入双引号。
// \\ 插入反斜杠字符。

let str1 = "She said \"Hello!\" to me."
let str2 = #"She said "Hello!" to me."#
//str is "She said "Hello!" to me."

print("str1 is \"\(str1)\"")
print("str2 is \"\(str2)\"")


The escaped special characters \0 (null character), \\ (backslash), \t (horizontal tab), \n (line feed), \r (carriage return), \" (double quotation mark) and \' (single quotation mark)