python转换时间戳和日期时间格式的转换

[steven@txzxp2 seccenter]$ python
Python 2.7.5 (default, Jul  8 2013, 09:48:59) 
[GCC 4.8.1 20130603 (Red Hat 4.8.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> import time
>>> dateC=datetime.datetime(2013,9,5,11,00,00)
>>> timestamp=time.mktime(dateC.timetuple())
>>> print timestamp
1378350000.0
>>> ltime=time.localtime(1378350000)
>>> timeStr=time.strftime("%Y-%m-%d %H:%M:%S", ltime)
>>> print timeStr
2013-09-05 11:00:00
>>> 

你可能感兴趣的:(python)