0
我想写一个Python
代码,其中用户给出一个数字和它想要四舍五入到小数的位数。然后该程序以科学记数法返回第一个数字。Python的估计
我的代码:
def csign(a,b):
#a=number,b=decimals
a=float(a)
b=float(b)
return "{:.b e}".format(a)
所需的功能应该像:
input: csign(123456,3)
output: 1.23 e5
但我得到一个错误说
Format specifier missing precision.
有什么办法,我可以使程序将b
识别为精度?