Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

ensure string length 2 python

month = "02"
month.zfill(2) #this will return "02" as it mantains the length of the string

month = "2"
month.zfill(2) # this will add the "0" before the "2" ensuring length == 2
 
PREVIOUS NEXT
Tagged: #ensure #string #length #python
ADD COMMENT
Topic
Name
4+8 =