小编Lil*_*123的帖子

使用Python编辑和创建HTML文件

我是Python新手.我目前正致力于使用python创建HTML文件的任务.我理解如何将HTML文件读入python,然后编辑并保存.

table_file = open('abhi.html', 'w')
table_file.write('<!DOCTYPE html><html><body>')
table_file.close()
Run Code Online (Sandbox Code Playgroud)

上面这篇文章的问题是它只是替换整个HTML文件并将字符串放在write()中.如何编辑文件,同时保持其内容不变.我的意思是,写这样的东西,但在身体标签内

<link rel="icon" type="image/png" href="img/tor.png">
Run Code Online (Sandbox Code Playgroud)

我需要链接自动进入开始和结束的身体标签之间.

html python python-import python-3.x

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

html ×1

python ×1

python-3.x ×1

python-import ×1