最佳答案
使用%-format,我可以在一个字符串中指定十进制大小写的数目:
x = 3.14159265
print('pi = %0.2f' %x)
这会给我:
pi = 3.14
在 Python 3.6中有没有使用 f-string 来实现这一点的方法?