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