在本文中,我们将看到使用python以非常独特的方式显示文本的方式有何不同。
因此,假设我要显示“ Hello,Python”,并通过多种方式可以显示文本/字符串(“ Hello,Python”),例如:
“Hello, Python”
___ ___ .__ .__ / | \ ____ | | | | ____ / ~ \_/ __ \| | | | / _ \ \ Y /\ ___/| |_| |_( <_> ) \___|_ / \___ >____/____/\____/ /\ \/ \/ )/ __________ __ .__ \______ \___.__._/ |_| |__ ____ ____ | ___< | |\ __\ | \ / _ \ / \ | | \___ | | | | Y ( <_> ) | \ |____| / ____| |__| |___| /\____/|___| / \/ \/ \/
_ _ _____ _ _ ___ ______ _______ _ _ ___ _ _ | | | | ____| | | | / _ \ | _ \ \ / /_ _| | | |/ _ \| \ | | | |_| | _| | | | | | | | | | |_) \ V / | | | |_| | | | | \| | | _ | |___| |___| |__| |_| | | __/ | | | | | _ | |_| | |\ | |_| |_|_____|_____|_____\___( ) |_| |_| |_| |_| |_|\___/|_| \_|
## ## # # # ## ## # # # ## ## ### # # # # # ### ####### # # ##### # #### ### ### # # # ##### ##### ## ## # # # # # ###### ## ### ## # # # # ####### # ## ## # # # # ######## ###### ######## ### # # # # ### # # ##### # ####### # # # ## # ## ## # ### # # # # ####### ## ## # # # ## # ### # #### # # # # # ##### ## ## ## # ## # ## #### ##### # # # # # #### # ## ## # ### # ##### # # # # ## # ## ## ## # ## ### ### # ## ###
上面只是冰袋的一角,您可以使用许多其他字体样式来显示文本。
我将使用python pyfiglet模块,该模块会将我的常规字符串转换为ASCII艺术字体。要安装pyfiglet,只需运行:
$pip install pyfiglet
在您的终端窗口中,就可以了。
>>> import pyfiglet >>> ascii_banner = pyfiglet.figlet_format("HELLO, PYTHON") >>> print(ascii_banner) _ _ _____ _ _ ___ ______ _______ _ _ ___ _ _ | | | | ____| | | | / _ \ | _ \ \ / /_ _| | | |/ _ \| \ | | | |_| | _| | | | | | | | | | |_) \ V / | | | |_| | | | | \| | | _ | |___| |___| |__| |_| | | __/ | | | | | _ | |_| | |\ | |_| |_|_____|_____|_____\___( ) |_| |_| |_| |_| |_|\___/|_| \_| |/
>>> from pyfiglet import Figlet >>> custom_fig = Figlet(font='graffiti') >>> print(custom_fig.renderText('HELLO, PYTHON')) ___ ______________.____ .____ ________ / | \_ _____/| | | | \_____ \ / ~ \ __)_ | | | | / | \ \ Y / \| |___| |___/ | \ \___|_ /_______ /|_______ \_______ \_______ / /\ \/ \/ \/ \/ \/ )/ _______________.___.______________ ___ ________ _______ \______ \__ | |\__ ___/ | \\_____ \ \ \ | ___// | | | | / ~ \/ | \ / | \ | | \____ | | | \ Y / | \/ | \ |____| / ______| |____| \___|_ /\_______ /\____|__ / \/ \/ \/ \/
>>> from pyfiglet import Figlet >>> custom_fig = Figlet(font='bubble') >>> print(custom_fig.renderText('Hello, Python')) _ _ _ _ _ _ _ _ _ _ _ _ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ( H | e | l | l | o | , ) ( P | y | t | h | o | n ) \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
>>> custom_fig = Figlet(font='speed') >>> print(custom_fig.renderText('Hello, Python')) ______ __ ___________ ___ / / /_______ /__ /_____ __ /_/ /_ _ \_ /__ /_ __ \ _ __ / / __/ / _ / / /_/ /__ /_/ /_/ \___//_/ /_/ \____/_( ) _|/ ________ ___________ ___ __ \____ ___ /___ /______________ __ /_/ /_ / / / __/_ __ \ __ \_ __ \ _ ____/_ /_/ // /_ _ / / / /_/ / / / / /_/ _\__, / \__/ /_/ /_/\____//_/ /_/ /____/
因此,我的猜测是您很容易找到自己喜欢的字体,并使用pyfiglet生成了ASCII艺术横幅,以增强您的应用程序。