All right: Http://docs.python.org/library/datetime.html?highlight=datetime#datetime.tzinfo.
Source: http://hi.baidu.com/mvp_xuan/blog/item/1a34cf0830581b9ed0581b74.html
Antecedent: You need to read a task list on Google's server, and it turns out that the time result for this list is the timestamp (relative to the offset in seconds of 1970.1.1 00:00:00).
The raw processing data is as follows:
"Createtime": "1319425189282", \ n "updatetime": "1319425189282", \ n "accesstime": "1319425189282", \ n
The code is as follows:
——————————————————————————
Import Time
CreateValue = 1319425189282 #以毫秒为单位的时间, starting from 1970 to today
CreateValue = float (createvalue)
CreateValue/= 1000 #除以1000的原因是gmtime这个方法只能转换秒级, and the raw data is milliseconds
print time.gmtime (createvalue)
print time.strftime ('%y-%m-%d%h:%m:%s ', Time.gmtime (CreateValue))
——————————————————————————
Output:
C:\Python26\python.exe c:/users/mvp_xuan/desktop/learnpython/test2.py
Time.struct_time (tm_year=2011, tm_mon=10, tm_mday=24, tm_hour=2, tm_min=59, tm_sec=49, tm_wday=0, tm_yday=297, tm_ isdst=0)
2011-10-24 02:59:49
Process finished with exit code 0
Haha, this can be dealt with this millisecond level of the value.
"slowrate": "%.4f" (Float (r[u "slowrate"))
Round (r[u "Slowrate"],3), 3 means to save several decimal places.
Records =[]
Records.append ({"Channelid": "%s"% (r[u "Channelid"]), "accessdate": "%s"% (r[u "accessdate" "].strftime ("%y%m%d%h%m "))," Slowspeedcount ": Int (r[u" Slowspeedcount "])," slowrate ":"%.4f "(Float (r[u" slowrate "])
To view:
Http://docs.python.org/library/functions.html?highlight=float#float