我如何在此处使用\(Backslash)并在我打印时出现它?
print <<EOTEXT;
(`-') (`-') _<-. (`-')_ <-. (`-')
_(OO ) ( OO).-/ \( OO) ) .-> \(OO )_
,--.(_/,-.\(,------.,--./ ,--/ (`-')----. ,--./ ,-.)
\ \ / (_/ | .---'| \ | | ( OO).-. '| `.' |
\ / / (| '--. | . '| |)( _) | | || |'.'| |
_ \ /_) | .--' | |\ | \| |)| || | | |
\-'\ / | `---.| | \ | ' '-' '| | | |
`-' `------'`--' `--' `-----' `--' `--'
EOTEXT
这是我喜欢在游戏机中出现的ASCII艺术。看起来“ \”似乎都没有出现。有什么方法可以使它出现。
print <<EOTEXT;
(`-') (`-') _<-. (`-')_ <-. (`-')
_(OO ) ( OO).-/ \( OO) ) .-> \(OO )_
,--.(_/,-.\(,------.,--./ ,--/ (`-')----. ,--./ ,-.)
\ \ / (_/ | .---'| \ | | ( OO).-. '| `.' |
\ / / (| '--. | . '| |)( _) | | || |'.'| |
_ \ /_) | .--' | |\ | \| |)| || | | |
\-'\ / | `---.| | \ | ' '-' '| | | |
`-' `------'`--' `--' `-----' `--' `--'
EOTEXT
This is my ascii art that id like to show up in console. How ever it seems that " \ " doesnt show up. Is there a way that i can make it appear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在双引号的字符串文字中,
\
是逃生序列的开始。当紧随其后的是非单词字符时,它会导致该角色产生。例如,\ |
和\␠
分别分别为|
和一个空间。当然,\\
生成\
,因此我们可以在double-中使用\\
在其中我们想要\
引用字符串文字。there docs (
&lt;&lt;&lt;&lt;
string string string cliterals)充当双引号的字符串文字,除非遵循&lt;&lt;
的令牌是单引号。然后,弦乐产生的字符串与输入完全匹配。因此,我们可以选择将
\
预备到每个特殊字符(\
,$
和@
),或者我们我们可以简单地引用令牌。In double-quoted string literals,
\
is the start of an escape sequence. When followed by a non-word character, it causes that character to be produced. For example,\|
and\␠
produce|
and a space respectively. And of course,\\
produces\
, so we can use\\
where we want\
in double-quote string literals.Here docs (
<<
string literals) act as double-quoted string literals, unless the token that follows the<<
is single-quoted. Then the string produced matches the input exactly.So we have the option of prepending
\
to every special character (\
,$
and@
), or we can simply single-quote the token.