On 26/02/2011 02:21, s...@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 'datetime.datetime' >>> datetime.datetime.resolution = (0, 0, 0) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: can't set attributes of built-in/extension type 'datetime.datetime' Do I need to create my own class to extend datetime.datetime?
You could just truncate the result: datetime.datetime.now().isoformat(' ')[ : 19] -- http://mail.python.org/mailman/listinfo/python-list