py3k: datetime resolution / isoformat
clp2 at rebertia.com
Sat Feb 26 05:37:56 CET 2011
On Fri, Feb 25, 2011 at 6:21 PM, <spam at uce.gov> wrote:
> When I do:
> datetime.datetime.now().isoformat(' ')
> I get the time with the microseconds. The docs says:
> "if microsecond is 0 YYYY-MM-DDTHH:MM:SS+HH:MM".
> How do I set microsecond to 0?
> >>> datetime.datetime.microsecond = 0
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: can't set attributes of built-in/extension type
Here you're trying to modify the *class* itself, not an *instance* of
the class like you want to.
However, datetime.datetime instances are immutable anyway. You have to
create a new instance with the desired values, as Ned Deily
Your "From:" address is annoying.
More information about the Python-list