本文整理汇总了Python中HTML.writeto方法的典型用法代码示例。如果您正苦于以下问题:Python HTML.writeto方法的具体用法?Python HTML.writeto怎么用?Python HTML.writeto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML
的用法示例。
在下文中一共展示了HTML.writeto方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: package
# 需要导入模块: import HTML [as 别名]
# 或者: from HTML import writeto [as 别名]
class Document:
generator = HTML.META(name="generator",
content="HyperText package (Python)")
DOCTYPE = HTML.DOCTYPE
body_element = HTML.BODY
def __init__(self, *content, **attrs):
from HTML import HEAD, HTML
self.doctype = self.DOCTYPE
self.body = apply(self.body_element, content, attrs)
self.head = HEAD(self.generator)
if hasattr(self, 'style'): self.head.append(self.style)
if hasattr(self, 'title'): self.head.append(self.title)
self.html = HTML(self.head, self.body)
self.setup()
def setup(self): pass
def append(self, *items): map(self.body.content.append, items)
def __str__(self, indent=0, perlevel=2):
return join([self.doctype.__str__(indent, perlevel),
self.html.__str__(indent, perlevel)], '')
def writeto(self, fp=sys.stdout, indent=0, perlevel=2):
self.doctype.writeto(fp, indent, perlevel)
self.html.writeto(fp, indent, perlevel)