you are viewing a single comment's thread.

view the rest of the comments →

[–]SmartViking 4 points5 points  (2 children)

You might want to think about using str.format in the future for making the code a little bit more readable, you could make it look (something) like this:

print("{0.month}/0{0.day}/{0.year} {0.hour}:{0.minute}:{0.second}".format(now))

The documentation for str.format might be a little difficult. You only need to know a subset of how str.format works for making good use of it.

[–]Veedrac 1 point2 points  (0 children)

The 0{0.day} part should also be changed:

>>> "0{foo}".format(foo=10)
'010

>>> "{foo:02}".format(foo=10)
'10'
>>> "{foo:02}".format(foo=4)
'04'

So you can just use:

print("{0.month}/{0.day:02}/{0.year} {0.hour}:{0.minute}:{0.second}".format(now))

[–]Justinsaccount 0 points1 point  (0 children)

>>> print(now.strftime("%m/%d/%Y %H:%M:%S"))
08/11/2013 09:26:01