from datetime import datetime
strptime是类datetime的方法,不是模块datetime的方法
然后datetime.strptime("2010-07-08 00:00:00", "%Y-%m-%d %H:%M:%S")
import datetime
def s2dt(s, fmt = '%Y-%m-%d %H:%M:%S'):
return datetime.datetime.strptime(s, fmt)
if __name__ == '__main__':
print s2dt('2010-08-15 00:00:00').strftime('%m-%d, %Y, %H:%M%S')
datetime.strptime("2010-07-08 00:00:00", "%Y-%m-%d %H:%M:%S")