creer to_percent(x, d)
This commit is contained in:
@@ -62,9 +62,19 @@ def to_int(x):
|
||||
except ValueError:
|
||||
return 0
|
||||
|
||||
def to_percent(x):
|
||||
def to_percent(x, d):
|
||||
"""Takes a float and returns a string"""
|
||||
return (u"%.1f " % x).replace('.', ',') + "%"
|
||||
if x == 0:
|
||||
pc = ''
|
||||
elif d == 2:
|
||||
pc = u"%.2f " % x
|
||||
elif d == 3:
|
||||
pc = u"%.3f " % x
|
||||
else:
|
||||
pc = u"%.1f " % x
|
||||
if len(pc) > 0:
|
||||
pc += "%"
|
||||
return pc.replace('.', ',')
|
||||
|
||||
|
||||
@view_config(route_name='home', renderer='../templates/home.pt', permission='view')
|
||||
|
||||
Reference in New Issue
Block a user