ASCII字符绘图网站推荐及使用Python绘制ASCII字符画


推荐网站:

文字显示为ASCII字符画:

图片显示为ASCII字符画:

                             _
                          _ooOoo_
                         o8888888o
                         88" . "88
                         (| -_- |)
                         O\  =  /O
                      ____/`---'\____
                    .'  \\|     |//  `.
                   /  \\|||  :  |||//  \
                  /  _||||| -:- |||||_  \
                  |   | \\\  -  /'| |   |
                  | \_|  `\`---'//  |_/ |
                  \  .-\__ `-. -'__/-.  /
                ___`. .'  /--.--\  `. .'___
             ."" '<  `.___\_<|>_/___.' _> \"".
            | | :  `- \`. ;`. _/; .'/ /  .' ; |
            \  \ `-.   \_\_`. _.'_/_/  -' _.' /
  ===========`-.`___`-.__\ \___  /__.-'_.'_.-'================
                          `=--=-'                    


vscode插件:

koroFileHeader: https://github.com/OBKoro1/koro1FileHeader
用于一键生成文件头部注释并自动更新最后编辑人和编辑时间、函数注释自动生成和参数提取,同时提供几个预制的字符画。


Python库骚操作:

pyfiglethttps://github.com/pwaller/pyfiglet
库中可供使用的各种字体可以查看:http://www.figlet.org/examples.html

from pyfiglet import Figlet

f = Figlet(font='slant')
text = f.renderText('Python')
print(text)

执行结果:

    ____        __  __              
   / __ \__  __/ /_/ /_  ____  ____ 
  / /_/ / / / / __/ __ \/ __ \/ __ \
 / ____/ /_/ / /_/ / / / /_/ / / / /
/_/    \__, /\__/_/ /_/\____/_/ /_/ 
      /____/                        

同时可以配合 colorama 库为字符串上色:https://github.com/tartley/colorama

字体颜色背景颜色字体格式
名称ForeBackStyle
颜色BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESETBLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESETDIM, NORMAL, BRIGHT, RESET_ALL

注意:颜色都需要大写。

from pyfiglet import Figlet
from colorama import Fore

f = Figlet(font='slant')
text = f.renderText('Python')

print(Fore.GREEN + text)

在这里插入图片描述

不过需要注意的是,在windows上colorama不太好用,实测vscode、powershell和cmd中都不生效,不过PyCharm中可以使用。在Linux下使用效果正常。

此外还可以使用 rich 库代替 colorama :https://github.com/Textualize/rich/blob/master/README.cn.md
rich库的功能更加丰富,不仅可以对字符串上色还可以创建虚拟控制台,显示Emoji表情等。

from pyfiglet import Figlet
import rich

f = Figlet(font='slant')
text = f.renderText('Python')

rich.print(f'[red]{text}[/red]')

在这里插入图片描述

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐