使用Printf转义变量 [英] Escape Variables with Printf
本文介绍了使用Printf转义变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我想执行以下操作:
If I wanted to do the following:
fmt.Printf("Escape this -> %v... Do not escape this -> %v", "Unescaped")
如何逃避第一次出现的%v
?
How could I escape the first occurrence of %v
?
\%v
似乎不起作用.有什么想法吗?
\%v
doesn't seem to work. Any ideas?
推荐答案
您可以将%%用作文字%
You can use %% for literal %
%% a literal percent sign; consumes no value
这篇关于使用Printf转义变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文