Sre*_*ova 0 string-formatting go
我在 Golang 中有一个名为的字符串mystring,我想将它放在两个百分号之间(像这样%mystring%)。然而直到现在我还无法做到这一点。
我尝试过的事情是:
value := fmt.Sprintf("%%s%",mystring)
value := fmt.Sprintf("%s%s%s","%",mystring,"%")
value := fmt.Sprintf("/% %s/%",mystring)
Run Code Online (Sandbox Code Playgroud)
但是当我打印它时,最终我收到了一个nil. 示例:mystring 的值为“HelloWorld”,然后我得到:%HelloWorld%nil
现在我收到这个结果:
/%s/%!(NOVERB)%!(EXTRA string=HelloWorld)<nil>
Run Code Online (Sandbox Code Playgroud)
那么,我错过了什么?
谢谢。
| 归档时间: |
|
| 查看次数: |
4795 次 |
| 最近记录: |