Home  >  Q&A  >  body text

Placeholder issues in Python

Is this what the script means? - means there are two digits. If there are less than two digits, a space will be automatically added as a placeholder; d also means two digits, and 0 is used here as a placeholder.

阿神阿神2712 days ago814

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-05-18 10:57:27

    %(name)[width].[precision]typecode

    (name) is a named
    flags can have +,-,' or 0. + means right alignment. - means left alignment. '˜' is a space, which means padding a space to the left of the positive number to align it with the negative number. 0 means use 0 padding.
    width represents the display width
    precision represents the precision after the decimal point

    The %02d表示用0 padding here is filled with spaces by default. For details, please refer to string formatting (% operator)

    reply
    0
  • Cancelreply