python克里金生成asc_使用Python生成ASCII字符画

 2023-09-05 阅读 111 评论 0

摘要:使用Python生成ASCII字符画在很多的网站主页中或者程序的注释中会有一些好看的字符注释画。显得很牛逼的样子例如:知乎_____ _____ _____ _____/\ \ /\ \ /\ \ /\ \/::\____\ /::\ \ /::\ \ /::\ \/:::/ / \:::\ \ /::::\ \ /::::\ \/:::/ / \:::\ \ /::::::\ \ /:::::

使用Python生成ASCII字符画

在很多的网站主页中或者程序的注释中会有一些好看的字符注释画。显得很牛逼的样子

例如:

知乎

_____ _____ _____ _____

/\ \ /\ \ /\ \ /\ \

/::\____\ /::\ \ /::\ \ /::\ \

/:::/ / \:::\ \ /::::\ \ /::::\ \

/:::/ / \:::\ \ /::::::\ \ /::::::\ \

/:::/ / \:::\ \ /:::/\:::\ \ /:::/\:::\ \

/:::/____/ \:::\ \ /:::/__\:::\ \ /:::/__\:::\ \

/::::\ \ /::::\ \ /::::\ \:::\ \ /::::\ \:::\ \

/::::::\ \ _____ ____ /::::::\ \ /::::::\ \:::\ \ /::::::\ \:::\ \

/:::/\:::\ \ /\ \ /\ \ /:::/\:::\ \ /:::/\:::\ \:::\____\ /:::/\:::\ \:::\ \

/:::/ \:::\ /::\____\/::\ \/:::/ \:::\____\/:::/ \:::\ \:::| |/:::/__\:::\ \:::\____\

\::/ \:::\ /:::/ /\:::\ /:::/ \::/ /\::/ |::::\ /:::|____|\:::\ \:::\ \::/ /

\/____/ \:::\/:::/ / \:::\/:::/ / \/____/ \/____|:::::\/:::/ / \:::\ \:::\ \/____/

\::::::/ / \::::::/ / |:::::::::/ / \:::\ \:::\ \

\::::/ / \::::/____/ |::|\::::/ / \:::\ \:::\____\

/:::/ / \:::\ \ |::| \::/____/ \:::\ \::/ /

/:::/ / \:::\ \ |::| ~| \:::\ \/____/

/:::/ / \:::\ \ |::| | \:::\ \

/:::/ / \:::\____\ \::| | \:::\____\

\::/ / \::/ / \:| | \::/ /

\/____/ \/____/ \|___| \/____/

RESTful

______ _____ _____ _____ __

| ___ \ ___/ ___|_ _| / _| | |

| |_/ / |__ \ `--. | | | |_ _ __ __ _ _ __ ___ _____ _____ _ __| |__

| /| __| `--. \ | | | _| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /

| |\ \| |___/\__/ / | | | | | | | (_| | | | | | | __/\ V V / (_) | | | <

\_| \_\____/\____/ \_/ |_| |_| \__,_|_| |_| |_|\___| \_/\_/ \___/|_| |_|\_|

linux中有figlet,可以通过yum安装,下面的是用Python写的

pyfiglet

到https://github.com/pwaller/pyfiglet下载或者clone,

使用方法

解压文件,进入文件中,执行python setup.py install ,安装需要的包。

关于setup的理解:http://python.jobbole.com/82077/

安装成功后,在Python中使用 打印的时候直接在renderText中写相应的文字即可

from pyfiglet import Figlet

f = Figlet(font='slant') # 斜体 不slant是默认的字体 是不倾斜的

print(f.renderText('Django')) # 里面写需要的生成的文字,只支持英文

结果:

____ _

/ __ \ (_)___ _____ ____ _____

/ / / / / / __ `/ __ \/ __ `/ __ \

/ /_/ / / / /_/ / / / / /_/ / /_/ /

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

/___/ /____/

深入源码--找自己需要的字体

从font-DEFAULT_FONT-FigletFont类下面的getFonts方法。

打印所有的字体名:

from pyfiglet import Figlet,FigletFont

all_fonts=FigletFont().getFonts()

print(all_fonts)

在pycharm中可以在左侧的源码中定位,直接就找到了所有的文件。

打印的结果:

所有的字体

['1943____', '1row', '3-d', '3d_diagonal', '3x5', '4max', '4x4_offr', '5lineoblique', '5x7', '5x8', '64f1____', '6x10', '6x9', 'acrobatic', 'advenger', 'alligator', 'alligator2', 'alligator3', 'alpha', 'alphabet', 'amc3line', 'amc3liv1', 'amcaaa01', 'amcneko', 'amcrazo2', 'amcrazor', 'amcslash', 'amcslder', 'amcthin', 'amctubes', 'amcun1', 'aquaplan', 'arrows', 'ascii_new_roman', 'ascii___', 'asc_____', 'assalt_m', 'asslt__m', 'atc_gran', 'atc_____', 'avatar', 'a_zooloo', 'B1FF', 'banner', 'banner3-D', 'banner3', 'banner4', 'barbwire', 'basic', 'battlesh', 'battle_s', 'baz__bil', 'bear', 'beer_pub', 'bell', 'benjamin', 'big', 'bigchief', 'bigfig', 'binary', 'block', 'blocks', 'bolger', 'braced', 'bright', 'brite', 'briteb', 'britebi', 'britei', 'broadway', 'broadway_kb', 'bubble', 'bubble_b', 'bubble__', 'bulbhead', 'b_m__200', 'c1______', 'c2______', 'calgphy2', 'caligraphy', 'cards', 'catwalk', 'caus_in_', 'char1___', 'char2___', 'char3___', 'char4___', 'charact1', 'charact2', 'charact3', 'charact4', 'charact5', 'charact6', 'characte', 'charset_', 'chartr', 'chartri', 'chiseled', 'chunky', 'clb6x10', 'clb8x10', 'clb8x8', 'cli8x8', 'clr4x6', 'clr5x10', 'clr5x6', 'clr5x8', 'clr6x10', 'clr6x6', 'clr6x8', 'clr7x10', 'clr7x8', 'clr8x10', 'clr8x8', 'coil_cop', 'coinstak', 'cola', 'colossal', 'computer', 'com_sen_', 'contessa', 'contrast', 'convoy__', 'cosmic', 'cosmike', 'cour', 'courb', 'courbi', 'couri', 'crawford', 'crazy', 'cricket', 'cursive', 'cyberlarge', 'cybermedium', 'cybersmall', 'cygnet', 'c_ascii_', 'c_consen', 'DANC4', 'dancingfont', 'dcs_bfmo', 'decimal', 'deep_str', 'defleppard', 'demo_1__', 'demo_2__', 'demo_m__', 'devilish', 'diamond', 'dietcola', 'digital', 'doh', 'doom', 'dosrebel', 'dotmatrix', 'double', 'doubleshorts', 'drpepper', 'druid___', 'dwhistled', 'd_dragon', 'ebbs_1__', 'ebbs_2__', 'eca_____', 'eftichess', 'eftifont', 'eftipiti', 'eftirobot', 'eftitalic', 'eftiwall', 'eftiwater', 'epic', 'etcrvs__', 'e__fist_', 'f15_____', 'faces_of', 'fairligh', 'fair_mea', 'fantasy_', 'fbr12___', 'fbr1____', 'fbr2____', 'fbr_stri', 'fbr_tilt', 'fender', 'filter', 'finalass', 'fireing_', 'fire_font-k', 'fire_font-s', 'flipped', 'flowerpower', 'flyn_sh', 'fourtops', 'fp1_____', 'fp2_____', 'fraktur', 'funface', 'funfaces', 'funky_dr', 'future_1', 'future_2', 'future_3', 'future_4', 'future_5', 'future_6', 'future_7', 'future_8', 'fuzzy', 'gauntlet', 'georgi16', 'georgia11', 'ghost', 'ghost_bo', 'ghoulish', 'glenyn', 'goofy', 'gothic', 'gothic__', 'graceful', 'gradient', 'graffiti', 'grand_pr', 'greek', 'green_be', 'hades___', 'heart_left', 'heart_right', 'heavy_me', 'helv', 'helvb', 'helvbi', 'helvi', 'henry3d', 'heroboti', 'hex', 'hieroglyphs', 'high_noo', 'hills___', 'hollywood', 'home_pak', 'horizontalleft', 'horizontalright', 'house_of', 'hypa_bal', 'hyper___', 'ICL-1900', 'impossible', 'inc_raw_', 'invita', 'isometric1', 'isometric2', 'isometric3', 'isometric4', 'italic', 'italics_', 'ivrit', 'jacky', 'jazmine', 'jerusalem', 'joust___', 'katakana', 'kban', 'keyboard', 'kgames_i', 'kik_star', 'knob', 'konto', 'kontoslant', 'krak_out', 'larry3d', 'lazy_jon', 'lcd', 'lean', 'letters', 'letterw3', 'letter_w', 'lexible_', 'lildevil', 'lineblocks', 'linux', 'lockergnome', 'madrid', 'mad_nurs', 'magic_ma', 'marquee', 'master_o', 'maxfour', 'mayhem_d', 'mcg_____', 'merlin1', 'merlin2', 'mig_ally', 'mike', 'mini', 'mirror', 'mnemonic', 'modern__', 'modular', 'morse', 'morse2', 'moscow', 'mshebrew210', 'muzzle', 'nancyj-fancy', 'nancyj-improved', 'nancyj-underlined', 'nancyj', 'new_asci', 'nfi1____', 'nipples', 'notie_ca', 'npn_____', 'nscript', 'ntgreek', 'nvscript', 'o8', 'octal', 'odel_lak', 'ogre', 'ok_beer_', 'oldbanner', 'os2', 'outrun__', 'pacos_pe', 'panther_', 'pawn_ins', 'pawp', 'peaks', 'peaksslant', 'pebbles', 'pepper', 'phonix__', 'platoon2', 'platoon_', 'pod_____', 'poison', 'puffy', 'puzzle', 'pyramid', 'p_skateb', 'p_s_h_m_', 'r2-d2___', 'radical_', 'rad_phan', 'rad_____', 'rainbow_', 'rally_s2', 'rally_sp', 'rammstein', 'rampage_', 'rastan__', 'raw_recu', 'rci_____', 'rectangles', 'red_phoenix', 'relief', 'relief2', 'rev', 'reverse', 'ripper!_', 'road_rai', 'rockbox_', 'rok_____', 'roman', 'roman___', 'rot13', 'rotated', 'rounded', 'rowancap', 'rozzo', 'runic', 'runyc', 's-relief', 'sans', 'sansb', 'sansbi', 'sansi', 'santaclara', 'sblood', 'sbook', 'sbookb', 'sbookbi', 'sbooki', 'script', 'script__', 'serifcap', 'shadow', 'shimrod', 'short', 'skateord', 'skateroc', 'skate_ro', 'sketch_s', 'slant', 'slide', 'slscript', 'small', 'smallcaps', 'smisome1', 'smkeyboard', 'smpoison', 'smscript', 'smshadow', 'smslant', 'smtengwar', 'sm______', 'soft', 'space_op', 'spc_demo', 'speed', 'spliff', 'stacey', 'stampate', 'stampatello', 'standard', 'starstrips', 'starwars', 'star_war', 'stealth_', 'stellar', 'stencil1', 'stencil2', 'stforek', 'stop', 'straight', 'street_s', 'sub-zero', 'subteran', 'super_te', 'swampland', 'swan', 'sweet', 'tanja', 'tav1____', 'taxi____', 'tec1____', 'tecrvs__', 'tec_7000', 'tengwar', 'term', 'test1', 'thick', 'thin', 'threepoint', 'ticks', 'ticksslant', 'tiles', 'times', 'timesofl', 'tinker-toy', 'ti_pan__', 'tomahawk', 'tombstone', 'top_duck', 'train', 'trashman', 'trek', 'triad_st', 'ts1_____', 'tsalagi', 'tsm_____', 'tsn_base', 'tty', 'ttyb', 'tubular', 'twin_cob', 'twisted', 'twopoint', 'type_set', 't__of_ap', 'ucf_fan_', 'ugalympi', 'unarmed_', 'univers', 'usaflag', 'usa_pq__', 'usa_____', 'utopia', 'utopiab', 'utopiabi', 'utopiai', 'varsity', 'vortron_', 'war_of_w', 'wavy', 'weird', 'wetletter', 'whimsy', 'wow', 'xbrite', 'xbriteb', 'xbritebi', 'xbritei', 'xchartr', 'xchartri', 'xcour', 'xcourb', 'xcourbi', 'xcouri', 'xhelv', 'xhelvb', 'xhelvbi', 'xhelvi', 'xsans', 'xsansb', 'xsansbi', 'xsansi', 'xsbook', 'xsbookb', 'xsbookbi', 'xsbooki', 'xtimes', 'xtty', 'xttyb', 'yie-ar__', 'yie_ar_k', 'z-pilot_', 'zig_zag_', 'zone7___']

生成文件

遍历列表把生成的字体存入文件中

font_list=FigletFont().getFonts()

with open("fontout","w",encoding='utf8') as f:

for i in font_list:

# f.write(i)

a = Figlet(font=i)

f.write(i)

f.write("\n")

f.write(a.renderText('Django'))

f.write("\n")

文件内容:

Linux 系统中的figlet

安装

yum install figlet

使用

figlet xxx

指定字体

查看所有字体

showfigfonts

使用指定的字体

figlet -f smslant xxxx

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://808629.com/228.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 86后生记录生活 Inc. 保留所有权利。

底部版权信息