class FigletBuilder(object):
"""
Represent the internals of the build process
"""
def __init__(self, text, font, direction, width, justify):
self.text = list(map(ord, list(text)))
self.direction = direction
self.width = width
self.font = font
self.justify = justify
from pyfiglet import Figlet
import shutil
f = Figlet(font='ascii___')
def DrawText(text,center=True):
if center:
print(*[x.center(shutil.get_terminal_size().columns) for x in f.renderText(text).split("\n")],sep="\n")
else:
print(f.renderText(text))
DrawText('text',center=True)
您可以将关键字justify与'auto'、'left'、'center'、或'right'一起使用
我这样做:
我找不到一份像样的模块文档。 因此,我必须深入研究代码,找到FigletBuilder类构造函数的关键字。它是这样开始的:
main()函数(当前第865行)中的OptionParser也给出了如何使用关键字的指示,以防您想了解有关如何使用关键字参数的更多信息,但不想滚动大约1000行代码^^^
您可以巧妙地将
.center()
与shutil
模块一起使用:相关问题 更多 >
编程相关推荐