Py之dominate:python的dominate库的简介、安装、使用方法之详细攻略

编程入门 行业动态 更新时间:2024-10-23 23:19:36

Py之dominate:python的dominate库的简介、安装、使用方法之详细攻略

 

 

目录

dominate库的简介

dominate库的安装

dominate库的使用方法


 

 

 

 

dominate库的简介

     “dominate”是一个使用优雅DOM API创建和操作HTML文档的Python库。它允许您非常简洁地编写纯Python中的HTML页面,从而消除了学习另一种模板语言的需要,并允许您利用Python的更强大的功能。

 

dominate库的安装

pip install dominate

 

dominate库的使用方法

import dominate
from dominate.tags import *

doc = dominate.document(title='Dominate your HTML')

with doc.head:
    link(rel='stylesheet', href='style.css')
    script(type='text/javascript', src='script.js')

with doc:
    with div(id='header').add(ol()):
        for i in ['home', 'about', 'contact']:
            li(a(i.title(), href='/%s.html' % i))

    with div():
        attr(cls='body')
        p('Lorem ipsum..')

print(doc)

 

 

相关文章

dominate 2.3.1

 

更多推荐

Py之dominate:python的dominate库的简介、安装、使用方法之详细攻略

本文发布于:2023-06-14 08:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1453851.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:使用方法   攻略   简介   详细   Py

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!