您的位置:首页 > 编程语言 > Python开发

python下datetime类型的转换

2010-04-17 09:00 495 查看
print datetime.strptime("2010-04-01 00:04:57.277","%Y-%m-%d %H:%M:%S.%f")
参考文章: http://docs.python.org/library/datetime.html#strftime-strptime-behavior
DirectiveMeaningNotes
%aLocale’s abbreviated weekday name.
%ALocale’s full weekday name.
%bLocale’s abbreviated month name.
%BLocale’s full month name.
%cLocale’s appropriate date and time representation.
%dDay of the month as a decimal number [01,31].
%fMicrosecond as a decimal number [0,999999], zero-padded on the left(1)
%HHour (24-hour clock) as a decimal number [00,23].
%IHour (12-hour clock) as a decimal number [01,12].
%jDay of the year as a decimal number [001,366].
%mMonth as a decimal number [01,12].
%MMinute as a decimal number [00,59].
%pLocale’s equivalent of either AM or PM.(2)
%SSecond as a decimal number [00,61].(3)
%UWeek number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.(4)
%wWeekday as a decimal number [0(Sunday),6].
%WWeek number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday are considered to be in week 0.(4)
%xLocale’s appropriate date representation.
%XLocale’s appropriate time representation.
%yYear without century as a decimal number [00,99].
%YYear with century as a decimal number.
%zUTC offset in the form +HHMM or -HHMM (empty string if the the object is naive).(5)
%ZTime zone name (empty string if the object is naive).
%%A literal '%' character.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: