我有蟒蛇即一個list of dictionary
如何迭代python中的字典列表?
listofobs = [{'timestamp': datetime.datetime(2012, 7, 6, 12, 39, 52), 'ip': u'1.4.128.0', 'user': u'lovestone'}, {'timestamp': datetime.datetime(2012, 7, 6, 12, 40, 32), 'ip': u'192.168.21.45', 'user': u'b'}]
我想用所有的按鍵和listofobs
變量的值在Django的模板。例如:
對於第一次迭代:
timestamp = 7 july 2012, 12:39 Am
ip = 1.4.128.0
user = lovestone
和第二次迭代:
timestamp = 7 july 2012, 12:40 Am
ip = 192.168.21.45
user = b
等..