Python Forum
Formatting outputs created with .join command
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Formatting outputs created with .join command
#3
Just another way to pad with zeros - string method str.zfill(). It's actually more keystrokes than using f-string formatting but one can argue that more readable.


>>> for value in ("5", "25", "255", "2555"):
...     print(value.zfill(3))
...
005
025
255
2555
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: Formatting outputs created with .join command - by perfringo - Aug-23-2023, 08:52 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  format json outputs ! evilcode1 3 1,781 Oct-29-2023, 01:30 PM
Last Post: omemoe277
  I have written a program that outputs data based on GPS signal kalle 1 1,211 Jul-22-2022, 12:10 AM
Last Post: mcmxl22
  Why does absence of print command outputs quotes in function? Mark17 2 1,416 Jan-04-2022, 07:08 PM
Last Post: ndc85430
  Thoughts on interfacing with a QR code reader that outputs keystrokes? wrybread 1 1,510 Oct-08-2021, 03:44 PM
Last Post: bowlofred
  Combining outputs into a dataframe rybina 0 1,701 Mar-15-2021, 02:43 PM
Last Post: rybina
  ONE input => THREE outputs Tricia279 6 2,710 Jan-14-2021, 08:52 AM
Last Post: perfringo
  The difference between os.path.join( and os.sep.join( Pedroski55 2 9,536 Nov-17-2020, 08:38 AM
Last Post: Pedroski55
  Multi set string inputs/outputs kwmcgreal 2 2,107 Sep-26-2020, 10:44 PM
Last Post: kwmcgreal
  How to use subprocess to get multiple data outputs in desired folder? 3SG14 1 2,257 Sep-19-2020, 05:46 PM
Last Post: bowlofred
  Outputs missing SamAnw 4 2,674 Feb-12-2020, 04:32 PM
Last Post: adetheheat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020