Python控制包|将<style>添加到html

时间:2019-01-01 00:23:25

标签: python html css dominate

我正在尝试使用python中的domin包生成一个html。对于格式,我必须在标签中添加简短的CSS内容。但是,我能找到的唯一文档是github页面,并且该页面没有任何与添加。有人可以帮我这个忙吗?谢谢!

Ps:这是一张图片

1 个答案:

答案 0 :(得分:0)

这是您的追求吗? from here

private void calDatePicker_DateChanged(CalendarDatePicker sender, CalendarDatePickerDateChangedEventArgs args)
{
        if (calDatePicker.Date < DateTime.Now)
        {
            dateText.Text = "Order must be placed between this day and next 5 days.";
        }
        else
        {
            dateText.Text = calDatePicker.Date.ToString();
            counter = true;
        }            
}

它产生;

import dominate
from dominate.tags import link, script, style

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

with doc.head:
    link(rel='stylesheet', href='style.css')
    script(type='text/javascript', src='script.js')
    style("""\
         body {
             background-color: #F9F8F1;
             color: #2C232A;
             font-family: sans-serif;
             font-size: 2.6em;
             margin: 3em 1em;
         }

     """)

print(doc.render(pretty=True))