I have this string:
' 2012-02-10 ' # (年度蒙日)
andineedittobeasdatetypeformetousethedatefunctionisoweekday ()。
doesanyoneknowhowicanconvertthisstringintoadate?
youcandothatwithdatetime.strp time (
Example:
来自数据导入数据时间
datetime.strptime('2012-02-10 ',' %Y-%m-%d ' ) )
datetime.datetime(2012、2、10、0、0 ) )。
_.isoweekday () )。
5
youcanfindthetablewithallthestrptimedirectivehere。
toincrementby2days if.is weekday (==6,you can use timedelta ) ) :
导入日期时间
date=datetime.datetime.strp time (' 2012-02-11 ',' %Y-%m-%d ' ) )
if date.isoweekday ()==6:
. date=datetime.timedelta(days=2) )。
.
日期
datetime.datetime(2012、2、13、0、0 ) )。
date.strftime('%y-%m-%d ' ) # if you want a string again
' 2012-02-13 '