【发布时间】:2010-10-02 00:13:51
【问题描述】:
我正在尝试替换日历模块中的两种方法:
import calendar
c = calendar.HTMLCalendar(calendar.MONDAY)
def ext_formatday(self, day, weekday, *notes):
if day == 0:
return '<td class="noday"> </td>'
if len(notes) == 0:
return '<td class="%s">%d<br /></td>' % (self.cssclasses[weekday], day)
else:
return '<td class="%s">%d<br />%s</td>' % (self.cssclasses[weekday], day, notes)
def ext_formatweek(self, theweek, *notes):
if len(notes) == 0:
s = ''.join(self.formatday(d, wd) for (d, wd) in theweek)
else:
s = ''.join(self.formatday(d, wd, notes) for (d, wd) in theweek)
return '<tr>%s</tr>' % s
c.formatday = ext_formatday
c.formatweek = ext_formatweek
print c.formatmonth(2012,1,"foobar")
这行不通 - 有人可以指点我相关的文献或指出我做错了什么吗? 我正在尝试从以下线程中实施 Alan Hynes 的建议:thread 我现在想清楚已经太晚了,我已经围绕这个问题讨论了一个多小时。
提前致谢,
雅库布
【问题讨论】: