0
我从Arduino接收数据,使用Python解析它,我的意图是使用串行数据更新HTML中的值。像<h6>value</h6>
,所以当我刷新页面时,新值将在那里。怎么做?如何使用Python更新HTML文件中的值?
我从Arduino接收数据,使用Python解析它,我的意图是使用串行数据更新HTML中的值。像<h6>value</h6>
,所以当我刷新页面时,新值将在那里。怎么做?如何使用Python更新HTML文件中的值?
我不确定你的情况,但是,我们使用python作为服务器端语言,并且为了制作动态HTML,我们使用为Django(基于python的框架)开发的Django模板。 下面是一个使用一些数据制作简单html的示例:
<!DOCTYPE html>
<html>
<head>
<meta name="keywords" content="{{ meta.keywords }}" />
<meta name="robots" content="index,follow" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="HandheldFriendly" content="true"/>
<title>{{ meta.title}}</title>
<meta name="description" content="{{ meta.description }}">
<meta name="og:description" content="{{ meta.description }}">
<meta property="og:title" content="{{ meta.title }}" />
<meta property="og:image" content="{{ meta.image_url}}" />
<meta property="og:image:type" content="image/png" />
<meta name="author" content="Yara Information Technology">
<meta http-equiv="X-UA-Compatible" content="IE=edge" charset="utf-8">
{% if data.type == 1 %}
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Recipe",
"name": "{{ data.title }}",
"author": "{{ data.author }}",
"image": "{{ data.image_url }}",
"description": "{{ data.short_desc }}",
"prepTime": "{{ data.prep_time }}",
"totalTime": "{{ data.total_time }}",
"nutrition": {
"@type": "NutritionInformation",
"servingSize": "{{ data.serve_count}}",
"calories": "{{ data.calories }}",
"fatContent": "{{ data.fat }}",
"carbohydrateContent": "{{ data.carbo}}",
"proteinContent": "{{ data.protein }}"
},
"recipeIngredient": [
{% for ingred in data.ingredients %}
"{{ ingred.title }} {{ingred.amount}} {{ ingred.rate }}",
{% endfor %}
],
"recipeInstructions": [
{%for step in data.list1 %}
"{{ forloop.counter }} - {{step.description }}",
{% endfor %}
]
}
</script>
{% endif %}
</head>
<body>
<h1>{{ data.title }}</h1>
<h2>{{ data.description }}</h2>
{% if data.additional_info %}
<p>
{{ data.additional_info }}
</p>
{% endif %}
{% if data.list1|length > 0 %}
{% for item in data.list1 %}
<h2>{{ item.title }}</h2>
<p>
{{ item.content }}
</p>
{% endfor %}
{% endif %}
{% if data.list2|length > 0 %}
{% for item in data.list2 %}
<h2>{{ item.title }}</h2>
<p>
{{ item.content }}
</p>
{% endfor %}
{% endif %}
{% if data.list3|length > 0 %}
{% for item in data.list3 %}
<h2>{{ item.title }}</h2>
<p>
{{ item.content }}
</p>
{% endfor %}
{% endif %}
</body>
</html>
所以说像我想上传一些图像我的网站的文件夹,这个HTML文件可以检测到有多少图像,并显示正确的图像数量? – bakalolo
解析结果是什么? – Charlie
4个变量与数值 – Mikael