擅长:python、mysql、java
<p>您可以将关键字<strong>justify</strong>与<strong>'auto'、'left'、'center'、</strong>或<strong>'right'</strong>一起使用</p>
<p>我这样做:</p>
<pre><code>import pyfiglet
txt = "title"
banner = pyfiglet.figlet_format(txt, font="slant", justify="center")
print(banner)
</code></pre>
<p>我找不到一份像样的模块文档。
因此,我必须深入研究代码,找到FigletBuilder类构造函数的关键字。它是这样开始的:</p>
<pre><code>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
</code></pre>
<p><strong>main()</strong>函数<em>(当前第865行)</em>中的<strong>OptionParser</strong>也给出了如何使用关键字的指示,以防您想了解有关如何使用关键字参数的更多信息,但不想滚动大约1000行代码^^^</p>