英文:
How Can I split a string by the character "
问题
这是我拥有的内容,我尝试进行拆分,像这样:
(使用Golang)
idPost = strings.Split(idPost, "'")
但编译器报错说使用了不兼容的赋值符号 "'".
英文:
That is what I have, and I tried to split like:
(Using Golang)
idPost = strings.Split(idPost,'"')
but the compiler said IncompatibleAssign using '"'.
答案1
得分: 5
使用反引号(back quote)而不是撇号(apostrophe),例如:
idPost = strings.Split(idPost, `"`)
英文:
Use a back quote instead of an apostrophe, example:
idPost = strings.Split(idPost,`"`)
答案2
得分: 1
你需要对它进行转义,所以你的问题是如何在Go语言中转义字符。
你会发现这在许多语言中都是类似的:
dPost = strings.Split(idPost,"\\")
英文:
you need to escape it, so your question is how to escape characters in go.
You will find this is similar across many languages:
dPost = strings.Split(idPost,"\"")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论