• Django框架模板语法之for表单应用!!!


    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    </head>
    <body>
    <h2>模板语法</h2>
    <h3>变量渲染之深度查询</h3>
    <p>姓名: {{ name }}</p>
    <p>四大名著: {{ books }}</p>
    <p>四大名著第三本: {{ books.2 }}</p>
    <p>个人信息: {{ info }}</p>
    <p>个人信息 姓名: {{ info.name }}</p>
    <p>个人信息 年龄: {{ info.age }}</p>
    <p>stus中第三个学生的姓名:{{ stus.2.name }}</p>

    <h3>过滤器</h3>
    {#{{val|过滤器函数:参数}}#}
    <p>当前时间:{{now|date:"Y-m-d"}}</p>
    <p>文件大小:{{fileSize|filesizeformat}}</p>

    <h3>for标签</h3>
    #<ur>
    # <li>{{ books.0 }}</li>
    # <li>{{ books.1 }}</li>
    # <li>{{ books.2 }}</li>
    # <li>{{ books.3 }}</li>

    #</ur>

    <ur>
    {% for book in book %}
    <li>{{ book }}</li>
    {% endfor %}
    </ur>

    <div class="row">
    <div class="col-md-8 col-md-offset-2">
    <table class="table table-bordered table-striped">
    <tr>
    <th>省份</th>
    <th>新增疑似</th>
    <th>累计疑似</th>
    <th>新增确诊</th>
    </tr>
    <tr>
    <td>北京</td>
    <td>0</td>
    <td>1</td>
    <td>21</td>
    </tr>
    <tr>
    <td>衡水</td>
    <td>0</td>
    <td>0</td>
    <td>0</td>
    </tr>
    </table>
    </div>

    </div>

    </body>
    </html>
    from django.test import TestCase

    # Create your tests here.

    import requests
    res = requests.get("https://2019ncov.chinacdc.cn/JKZX/yq_20220401.json")
    # print(res.json())
    data = res.json()["features"]

    #print(data)

    for item in data:
    # print(item.get("properties"))
    name = item.get("properties").get("name")
    a = item.get("properties").get("新增疑似")
    b = item.get("properties").get("累计疑似")
    c = item.get("properties").get("新增确诊")
    print(name, a, b, c)




     

  • 相关阅读:
    [LeetCode] 806. Number of Lines To Write String
    [LeetCode] 728. Self Dividing Numbers
    [LeetCode] 852. Peak Index in a Mountain Array
    [LeetCode] 617. Merge Two Binary Trees
    [LeetCode] 876. Middle of the Linked List
    [LeetCode] 461. Hamming Distance
    不会装电脑?手把手教你装电脑,详细到螺丝!
    零基础到精通Web渗透测试的学习路线
    EXE转JPG后缀格式工具(真实JPG后缀)
    知名渗透测试利器分享
  • 原文地址:https://www.cnblogs.com/A121/p/16428413.html
Copyright © 2020-2023  润新知