一尘不染

(快速)如何在字符串中打印“ \”字符?

swift

我曾尝试打印它,但由于它是转义字符,因此只是通过而已。例如,输出应如下。

\correct

提前致谢


阅读 629

收藏
2020-07-07

共1个答案

一尘不染

为此以及将来的参考:

\0 – Null character (that is a zero after the slash)
\\ – Backslash itself.  Since the backslash is used to escape other characters, it needs a special escape to actually print itself.
\t  – Horizontal tab
\n – Line Feed
\r  – Carriage Return
\”  – Double quote.  Since the quotes denote a String literal, this is necessary if you actually want to print one.
\’  – Single Quote.  Similar reason to above.
2020-07-07