本文整理汇总了Python中future.backports.email.generator.Generator方法的典型用法代码示例。如果您正苦于以下问题:Python generator.Generator方法的具体用法?Python generator.Generator怎么用?Python generator.Generator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类future.backports.email.generator
的用法示例。
在下文中一共展示了generator.Generator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: as_string
# 需要导入模块: from future.backports.email import generator [as 别名]
# 或者: from future.backports.email.generator import Generator [as 别名]
def as_string(self, unixfrom=False, maxheaderlen=0):
"""Return the entire formatted message as a (unicode) string.
Optional `unixfrom' when True, means include the Unix From_ envelope
header.
This is a convenience method and may not generate the message exactly
as you intend. For more flexibility, use the flatten() method of a
Generator instance.
"""
from future.backports.email.generator import Generator
fp = StringIO()
g = Generator(fp, mangle_from_=False, maxheaderlen=maxheaderlen)
g.flatten(self, unixfrom=unixfrom)
return fp.getvalue()