Reputation: 7139
How come this works:
import datetime
now = datetime.datetime.now()
month = '%d' % now.month
print month
But this doesn't?
import datetime
now = datetime.datetime.now()
month = '%m' % now.month
print month
Thanks!
Upvotes: 0
Views: 238
Reputation: 114933
%m is not a supported format character for the % operator. Here is the list of supported formating characters for this operator
%m is valid when your are using strftime function to build a date string
Upvotes: 3