is there proper way handle percentages in python?
for example, how handle value 0.01 , make displayed 1%
you can use str.format()
percentage = 0.01 print "{0:.0f}%".format(percentage * 100) 1%
percentage = 0.0142 print "{0:.0f}%".format(percentage * 100) 1%
percentage = 0.0142 print "{0:.1f}%".format(percentage * 100) 1.4%
Comments
Post a Comment