Issue with datetime-python module

How it works:

import datetime
now = datetime.datetime.now()
month = '%d' % now.month

print month

      

But isn't it?

import datetime
now = datetime.datetime.now()
month = '%m' % now.month

print month

      

Thanks!

0


a source to share


2 answers


% m is not supported by the format character for the% operator. Below is a list of supported character shaping for this operator



% m is valid if you use strftime to create a date string

+3


a source


'%d'

is a format character that inserts a "signed integer" '%m'

has no such meaning. Possible format characters are listed here .



+1


a source







All Articles