Re: True/False formats as 1/0 in a fixed width string

Discussion in 'Python' started by Peter Otten, Mar 27, 2013.

  1. Peter Otten

    Peter Otten Guest

    Frank Millman wrote:

    > >>> '{}'.format(True)

    > 'True'
    > >>> '{:<10}'.format(True)

    > '1 '
    >
    > One might want to format True/False in a fixed width string, but it
    > returns 1/0 instead. Is there any way to make this work?


    >>> "{!s:<10}".format(True)

    'True '
    Peter Otten, Mar 27, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bdb112
    Replies:
    45
    Views:
    1,321
    jazbees
    Apr 29, 2009
  2. Frank Millman
    Replies:
    0
    Views:
    86
    Frank Millman
    Mar 27, 2013
  3. Dave Angel
    Replies:
    0
    Views:
    117
    Dave Angel
    Mar 27, 2013
  4. Frank Millman
    Replies:
    0
    Views:
    111
    Frank Millman
    Mar 27, 2013
  5. Frank Millman
    Replies:
    0
    Views:
    119
    Frank Millman
    Mar 27, 2013
Loading...

Share This Page