2018-05-20 python 时间格式转换 编程 python datetime和str123456# str转datetimedatetime.datetime.strptime('2017-04-23 00:00:00', '%Y-%m-%d %H:%M:%S')# datetime转strdatetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S');# datetime转timestamptime.mktime(dt.timetuple()) utc时间转本地时间123456from_zone = tz.tzutc()to_zone = tz.tzlocal()utc = datetime.strptime(utcs, '%Y-%m-%dT%H:%M:%SZ')utc = utc.replace(tzinfo=from_zone)local_dt = utc.astimezone(to_zone)dts = local_dt.strftime('%Y-%m-%d %H:%M') datetime转timestamp12datetime.fromtimestamp(ts)datetime.utcfromtimestamp(ts) scp linux date命令