How to add percent sign in string format?
本问题已经有最佳答案,请猛点这里访问。
我想从
1 2 3 | let rate = 99.99999 let str = String(format:"%.2f%", rate) // output 99.99 |
不允许使用
写两次%:
1 2 | rate = 99.99 let str = String(format:"%.2f%%", rate) |
The % symbol has a special use in a printf statement. How would you
place this character as part of the output on the screen?
您可以在printf语句中使用'%'。例如,您可以写入printf("10%")使输出在屏幕上显示为10%。
希望它能帮助你:)