![]() Python f-strings allow us to make string formatting a little bit more intuitive. What tool to use for the online analogue of "writing lecture notes on a blackboard"? WebExample 1: python convert number to string with leading zeros str(1).zfill(2) # 1 will be '01' str(23).zfill(4) # 23 will be '0023' Example 2: python3 format leading Menu NEWBEDEV Python Javascript Linux Cheat sheet The str.zfill() function is exclusively designed to pad a string with zeros towards its left side.
0 Comments
Leave a Reply. |