时间字符串转换为时间戳:

import time
timestring = '2012-05-15 17:12:37'
timestamp = int(time.mktime(time.strptime(timestring, '%Y-%m-%d %H:%M:%S')))
print timestamp

时间戳转换为时间字符串:

import time
struct_time = time.localtime(1337073342)
timestring = time.strftime('%Y-%m-%d %H:%M:%S',struct_time)
print timestring