我试图创建一个以时间戳为键的字典。代码是:
>>> stamp = datetime.datetime(2012, 4, 12, 12, 26, int('13'))
>>> new_dict = {}
>>> new_dict[stamp] = 'one'
>>> print new_dict
{datetime.datetime(2012, 4, 12, 12, 26, 13): 'one'}
>>> print stamp
2012-04-12 12:26:13
为什么不将键作为“2012-04-12 12:26:13”,而是将表达式“datetime.datetime()”作为键?