python - Can I operate on formatted strings? -


a snippet of python code:

def somemethod():     return datetime.date.today().strftime("%b" + " " + "%d".lstrip('0') + ", " + "%y") 

how come returns:

june 03, 2015 

and not expected, was:

june 3, 2015 

thanks help.

"%d".lstrip('0') "%d", "%d" never had zeroes in begin with. if asking if can operate on different parts formatted strftime, answer no. can influence formatting precision.

see this answer alternative, , this answer on same question another, possibly non-portable alternative.


Comments