赞
踩
FIGlet 是一种生成各种类型的文本的程序,例如用较小的 ASCII 字符组成
pyfiglet
是一款 Python 实现的 figlet
pip install pyfiglet
from pyfiglet import Figlet
f = Figlet(font='slant')
print(f.renderText('Hello World!'))
效果
__ __ ____ _ __ __ ____
/ / / /__ / / /___ | | / /___ _____/ /___/ / /
/ /_/ / _ \/ / / __ \ | | /| / / __ \/ ___/ / __ / /
/ __ / __/ / / /_/ / | |/ |/ / /_/ / / / / /_/ /_/
/_/ /_/\___/_/_/\____/ |__/|__/\____/_/ /_/\__,_(_)
from pyfiglet import FigletFont
print(FigletFont().getFonts())
安装
pyfiglet -L <font file>
内置 Figlet 字体不支持中文
安装
sudo apt update
sudo apt install figlet
sudo apt install toilet
把 .flf
或 .flc
字体放在 /usr/share/figlet
查看可用字体
showfigfonts
figlist
命令
figlet XerCis
echo 'Hello, World!' | figlet
figlet -f big 'XerCis'
toilet XerCis
效果
__ __ ____ _
\ \/ /___ _ __ / ___(_)___
\ // _ \ '__| | | / __|
/ \ __/ | | |___| \__ \
/_/\_\___|_| \____|_|___/
_ _ _ _ __ __ _ _ _
| | | | ___| | | ___ \ \ / /__ _ __| | __| | |
| |_| |/ _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` | |
| _ | __/ | | (_) | \ V V / (_) | | | | (_| |_|
|_| |_|\___|_|_|\___( ) \_/\_/ \___/|_| |_|\__,_(_)
|/
__ __ _____ _
\ \ / / / ____(_)
\ V / ___ _ __| | _ ___
> < / _ \ '__| | | / __|
/ . \ __/ | | |____| \__ \
/_/ \_\___|_| \_____|_|___/
m m mmm "
# # mmm m mm m" " mmm mmm
## #" # #" " # # # "
m""m #"""" # # # """m
m" "m "#mm" # "mmm" mm#mm "mmm"
酷炫时钟
watch -n 1 "date '+%D%n%T' | figlet -k"
下载并安装中文字体
这三个理论上支持中文,但本人尝试失败
git clone https://github.com/cmatsuoka/figlet-fonts.git
cd figlet-fonts/cjkfonts
pyfiglet -L cns.flf
pyfiglet -L gb16fs.flf
pyfiglet -L gb16st.flf
1. 打印所有艺术字
from pyfiglet import Figlet, FigletFont
def show_all(text='Hello World!'):
for font in FigletFont().getFonts():
print('【{}】'.format(font))
print(Figlet(font).renderText(text))
show_all()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。