I am using python 3.4.3 . I have list of dict with following structure
test['content'] = [
{
"time_cre" : datetimeobject,
"name": "Sam",
"num": 123
},
{
"time_cre" : datetimeobject,
"name": "Sunil",
"num": 124
}
I use map and lambda function to convert datetime object to string. My code is
map((lambda x:x.update({'time_cre': x['time_cre'].strftime("%Y-%m-%d")})),test['content'])
The above method does not reflect anything.
test['new'] = map((lambda x:x.update({'time_cre': x['time_cre'].strftime("%Y-%m-%d")})),test['content'])
The above method works but the result is
{
'content':{
"time_cre" : "2017-06-03",
"name": "Sam",
"num": 123
},
{
"time_cre" : "2017-06-03",
"name": "Sunil",
"num": 124
}
],
'new': <map object at 0x7f70e1fe4208>
}
So why its is not working in first method and why working in second method. Can anybody explain.