python:小数点后返回零的百分比格式

python:小数点后返回零的百分比格式,python,format,Python,Format,我想把一些百分比打印到小数点后4位。我的代码如下所示 for i in range(len(candidates)): #looping through the results percentage_votes = "{:.4%}".format(results[i][1] / voters) #setting the number to a % print(f'{results[i][0]}: {percentage_votes} ({

我想把一些百分比打印到小数点后4位。我的代码如下所示

for i in range(len(candidates)):  #looping through the results
    percentage_votes = "{:.4%}".format(results[i][1] / voters)           #setting the number to a %
    print(f'{results[i][0]}: {percentage_votes} ({results[i][1]})')      #print result
当它打印时;但是,它没有给我除法的小数位数,而是返回小数点后4位的所有零

Khan: 63.0000% (2218231)
Correy: 20.0000% (704200)
Li: 14.0000% (492940)
O'Tooley: 3.0000% (105630)
我需要在代码中更正什么才能得到进一步的除数?谢谢

我试过这个

"{:.4%}".format(3.4445453543) 
输出:'344.4545%'

这让我想到可能是部门没有报告浮动

你能试试这个吗

"{:.4%}".format(results[i][1] / float(voters)) 

这回答了你的问题吗?