Skip to content

Commit a5bfd2e

Browse files
committed
html 生成
1 parent 7bdceec commit a5bfd2e

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ erl_crash.dump
1010
**/__pycache__
1111

1212
1-基础/wav文件处理/输出
13-
1-基础/图片处理/生成gif/*.gif
13+
1-基础/图片处理/生成gif/*.gif
14+
2.1-topic:数据处理/HTML生成/*.html
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
目标:
2+
- 生成语法正确的 HTML 源码文件
3+
- 包含相应自动测试代码
4+
- 可限定范围, 否则网页中包含所有支持的类型的界面元素
5+
- 段落文本内容参考<狗屁不通>, 带结构的界面元素使用内置的中文内容
6+
- 暂时不包含任何元素特性(attribute)
7+
- 如需要标识符, 尽量使用中文(包括元素 id 等等)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Python 3.7.3下测试通过
2+
# 参考: https://stackoverflow.com/a/48817000/1536803
3+
import sys
4+
from xml.etree import ElementTree as 结构
5+
6+
= 结构.Element('html')
7+
body = 结构.Element('body')
8+
.append(body)
9+
div = 结构.Element('div')
10+
body.append(div)
11+
span = 结构.Element('span')
12+
div.append(span)
13+
span.text = "待文本生成"
14+
15+
结构.ElementTree().write('测1.html', encoding='unicode', method='html')

0 commit comments

Comments
 (0)