Python将树转换为HTML日历

2024-04-25 08:13:23 发布

您现在位置:Python中文网/ 问答频道 /正文

使用这个:

def Tree(): return defaultdict(Tree)

我为日历创建可用日期树:

^{pr2}$

打印“\t\t日期:”,天

如何使这些日子成为HTML中唯一可用的日子?在

我使用瓶子,可以将树作为变量传入:

^{3}$

我的主菜/测试.tpl目前为止:

{{date_list}}
<br><br>        
<input type="date">

编辑:刚刚意识到输入type='date'在IE和chrome中不起作用。。。所以我可能需要使用datepicker或一些js?在


Tags: brtree瓶子inputdatereturndefhtml
1条回答
网友
1楼 · 发布于 2024-04-25 08:13:23

我找到了一个解决办法,但这可能是个问题。可能更像Python?在

首先,我把我的树改为有两位数的日期:

@bottle.route('/test')
def run_test_page():

    calendar = Tree()
    calendar['2013']['10']=['01','02','03','04','06']
    calendar['2013']['12']=['05','07','12']
    calendar['2013']['11']=['08','10','19']

    calendar['2014']['01']=['01','02','03','04','06']
    calendar['2014']['02']=['05','07','12']
    calendar['2014']['03']=['08','10','19']
    calendar['2014']['04']=['01','02','03','04']
    return bottle.template('main/test.tpl', {'date_list': calendar})

其次,这是测试.tpl文件(我知道我应该有一个单独的js文件):

^{pr2}$

相关问题 更多 >