R. David Murray added the comment:

You appear to be mixing up % style formatting and 'format' style formatting, 
especially since you seem to be using both in your examples, which is redundant.

Please see http://docs.python.org/2.7/library/string.html#format-string-syntax 
for the explanation of the format method, including the % presentation type.

Your questions will probably be answered better and more thoroughly if you post 
to the python-lits mailing list (the tracker is not a place to get help, I'm 
afraid), but some quick hints:  In Python2.7, 1/10 is 0. In a 'format' format 
string you can get what it sounds like you want by doing this:

  >>> '{:.2f}%'.format(12.67777)
  '12.68%'

In % style formatting you would do

  >>> '%.2f%%' % 12.67777
  '12.68%'

This is all well documented, but if you can see places it could be clarified, 
please let us know.

----------
nosy: +r.david.murray
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17207>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to