你如何在Go中编写多行字符串? [英] How do you write multiline strings in Go?
本文介绍了你如何在Go中编写多行字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Go有没有类似python的多行字符串:
line 1
line 2
第3行
如果不是,编写跨越多个字符串的首选方式是什么根据 rel =noreferrer> language specification 你可以使用一个原始字符串文字,其中的字符串由反引号而不是双引号分隔。
`line 1
line 2
line 3`
Does Go have anything similar to the python's multiline strings:
"""line 1
line 2
line 3"""
If not, what is the preferred way of writing strings spanning multiple lines?
解决方案
According to the language specification you can use a raw string literal, where the string is delimited by backticks instead of double quotes.
`line 1
line 2
line 3`
这篇关于你如何在Go中编写多行字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文