是否可以从 python 替换字段获取此输出?
'{:.1%}'.format(0.4) # -> 40.0 %
我想在数字后面有一个空格。
我当前的解决方法是:
'{:.1f} %'.format(0.4 * 100)
最佳答案
作为doc说,当您使用 %
格式运算符时,
it multiplies the number by 100 and displays in fixed ('f') format, followed by a percent sign.
没有空间或无法添加。
所以你的解决方法就是解决方案
关于python - 格式{:%}: Add space between digit and percentage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37023871/