如何使用“printf"打印“%"字符? [英] How do I print the '%' character with 'printf'?
本文介绍了如何使用“printf"打印“%"字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法弄清楚的简单问题...
Simple problem that I can't figure out...
如何在 printf
字符串中打印 '%' 字符?下面的代码打印了它,但也给出了无效转换"错误.
How can I print a '%' character within a printf
string? The code below prints it, but gives an 'invalid conversion' error as well.
printf "\t\t".$hour."00 HRS\t=>\t%.2f\t%.2f\t%.1f\%\n", $total, $max15, ($max15/$total*100);
应该输出类似:
0000 HRS => 3125.19 898.02 28.7%
推荐答案
您将使用 %%,而不是 \%(来自 man printf)
You would use %%, not \% (from man printf)
这篇关于如何使用“printf"打印“%"字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文