反引号(``)&之间有什么区别?Golang中的双引号(“")? [英] What is the difference between backticks (``) & double quotes ("") in golang?
本文介绍了反引号(``)&之间有什么区别?Golang中的双引号(“")?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
反引号(``)&在golang中用双引号(")?
What is the difference between backticks (``) & double quotes ("") in golang?
推荐答案
在引号""
中,您需要转义不需要在反引号中转义的新行,制表符和其他字符``
.如果在反引号字符串中插入换行符,则该换行符将被解释为'\ n'
字符,请参见 https://golang.org/ref/spec#String_literals
In quotes ""
you need to escape new lines, tabs and other characters that do not need to be escaped in backticks ``
. If you put a line break in a backtick string, it is interpreted as a '\n'
character, see https://golang.org/ref/spec#String_literals
因此,如果您在反引号字符串中说 \ n
,它将被解释为原义的反斜杠和字符n.
Thus, if you say \n
in a backtick string, it will be interpreted as the literal backslash and character n.
a := "\n" // This is one character, a line break.
b := `\n` // These are two characters, backslash followed by letter n.
这篇关于反引号(``)&之间有什么区别?Golang中的双引号(“")?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文