擅长:python、mysql、java
<p>你可以试试:</p>
<pre><code>import pyfiglet as pyfiglet
def to_color(string, color):
color_code = {'blue': '\033[34m',
'yellow': '\033[33m',
'green': '\033[32m',
'red': '\033[31m'
}
return color_code[color] + str(string) + '\033[0m'
result = pyfiglet.figlet_format("By Gxzs", font = "slant" )
print(to_color(result,'blue'))
</code></pre>
<p>有关ANSI Scape代码和颜色代码的详细信息<a href="https://en.wikipedia.org/wiki/ANSI_escape_code" rel="nofollow noreferrer">click here</a></p>