直接上代码:
def format_output(num, total, decimal_num, fill=""):
"""
total: 总长度
float_num: 小数点后保留位数
fill: 填充,默认空格,可选0
"""
new_num = f"{f'{num:.{decimal_num}f}':>{fill}{total}}"
return(new_num)
之前是将数字用split("
直接上代码:
def format_output(num, total, decimal_num, fill=""):
"""
total: 总长度
float_num: 小数点后保留位数
fill: 填充,默认空格,可选0
"""
new_num = f"{f'{num:.{decimal_num}f}':>{fill}{total}}"
return(new_num)
之前是将数字用split("