(斯威夫特)如何打印“\”字符串中的字符? [英] (Swift) how to print "\" character in a string?

查看:133
本文介绍了(斯威夫特)如何打印“\”字符串中的字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图打印它,但它只是通过,因为它是一个转义字符。
例如输出应如下所示。

I have tried to print it but it just by passes because it's an escaped character. e.g output should be as follows.

\correct

提前致谢

推荐答案

为此以及未来参考:

\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.

这篇关于(斯威夫特)如何打印“\”字符串中的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆