<!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)