小编kro*_*ron的帖子

计算Python中的日期是开始,未来还是现在

我有两个日期/时间字符串:

start_date = 10/2/2010 8:00:00  

end_date = 10/2/2010 8:59:00
Run Code Online (Sandbox Code Playgroud)

我需要编写一个函数来计算事件是否在将来,过去或者现在是否正在发生 - 我已经阅读了相当多的文档但是发现很难让它工作.

我在Python中没有用太多时间进行计算,所以任何帮助都会非常感激!

非常感谢

python django time datetime

8
推荐指数
1
解决办法
5616
查看次数

Django"for"循环和python字典问题

我有几个问题让循环标记的django模板通过这个字典:

它肯定被传递到页面,好像我只是做:

{% for event in events %}
   {{ event }} 
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

它写了1,2,3,但当我尝试做{{event.start}}时,它只是输出任何东西......

    evs = {

        "1": {
            'start': '8:00:00',
            'end': '9:00:00',
            'name': 'test',
            'description': 'test',
            'image_url': 'http://test',
            'channel_url': 'http://test',
        },

        "2": {
            'start': '8:00:00',
            'end': '9:00:00',
            'name': 'test',
            'description': 'test',
            'image_url': 'http://test',
            'channel_url': 'http://test',
        },

        "3": {
            'start': '8:00:00',
            'end': '9:00:00',
            'name': 'test',
            'description': 'test',
            'image_url': 'http://test',
            'channel_url': 'http://test',
        }

    }
Run Code Online (Sandbox Code Playgroud)

这是我在模板中的django代码:

    {% for event in events %}
            {{ event.end }}
            {{ event.name }}
            {{ event.description }} …
Run Code Online (Sandbox Code Playgroud)

python django

2
推荐指数
2
解决办法
2917
查看次数

标签 统计

django ×2

python ×2

datetime ×1

time ×1