Skip to content

Commit

Permalink
html 生成
Browse files Browse the repository at this point in the history
  • Loading branch information
testacount1 committed Nov 19, 2019
1 parent 7bdceec commit a5bfd2e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ erl_crash.dump
**/__pycache__

1-基础/wav文件处理/输出
1-基础/图片处理/生成gif/*.gif
1-基础/图片处理/生成gif/*.gif
2.1-topic:数据处理/HTML生成/*.html
7 changes: 7 additions & 0 deletions 2.1-topic:数据处理/HTML生成/READE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
目标:
- 生成语法正确的 HTML 源码文件
- 包含相应自动测试代码
- 可限定范围, 否则网页中包含所有支持的类型的界面元素
- 段落文本内容参考<狗屁不通>, 带结构的界面元素使用内置的中文内容
- 暂时不包含任何元素特性(attribute)
- 如需要标识符, 尽量使用中文(包括元素 id 等等)
15 changes: 15 additions & 0 deletions 2.1-topic:数据处理/HTML生成/测试.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Python 3.7.3下测试通过
# 参考: https://stackoverflow.com/a/48817000/1536803
import sys
from xml.etree import ElementTree as 结构

= 结构.Element('html')
body = 结构.Element('body')
.append(body)
div = 结构.Element('div')
body.append(div)
span = 结构.Element('span')
div.append(span)
span.text = "待文本生成"

结构.ElementTree().write('测1.html', encoding='unicode', method='html')

0 comments on commit a5bfd2e

Please sign in to comment.