复制代码 代码如下:
import datetime, calendar
lastFriday = datetime.date.today( )
oneday = datetime.timedelta(days=1)
lastFriday -= oneday
while lastFriday.weekday( ) != calendar.FRIDAY:
lastFriday -= oneday
print lastFriday.strftime('%A, %d-%b-%Y')
输出结果:
Friday, 09-May-2008