擅长:python、mysql、java
<p>您应该使用<code>datetime</code>模块来处理日期时间。您可以使用<code>datetime.datetime.strptime()</code>将字符串解析为<code>datetime.datetime</code>对象,然后使用<code>datetime.timedelta</code>并将所需的1小时添加到它,然后使用<code>datetime.datetime.strftime()</code>以所需格式将其解析回字符串。示例-</p>
<pre><code>d['timeTo'] = (datetime.datetime.strptime(d['timeFrom'],'%Y-%m-%dT%H:%M:%S.%fZ') + datetime.timedelta(hours=1)).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
</code></pre>
<p>演示-</p>
<pre><code>>>> d = {"resourceId": "5293e7fb-ffnksadjfn-7b-abfr185fsa6b", "count": "1", "timeFrom": "2016-01-15T01:35:30.314Z", "timeTo": "2016-01-15T01:35:30.314Z", "sourceId": "card_16m7TaFYUmuhEmVRMoEwnaXa", "notes":"fmaksf"}
>>> import datetime
>>> d['timeTo'] = (datetime.datetime.strptime(d['timeFrom'],'%Y-%m-%dT%H:%M:%S.%fZ') + datetime.timedelta(hours=1)).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
>>> d['timeTo']
'2016-01-15T02:35:30.314Z'
</code></pre>
<p>如果您使用的是python2.x,那么可以使用<code>str.decode()</code>方法将字符串解码为unicode对象,使用所需的编码。在Python3.x中,您会得到一个普通的unicode对象,因此不需要对其进行解码</p>