[{"data":1,"prerenderedAt":1108},["ShallowReactive",2],{"post-2026-03-05-pyfiglet-guide":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"tags":11,"body":14,"_type":1102,"_id":1103,"_source":1104,"_file":1105,"_stem":1106,"_extension":1107},"\u002Fblog\u002F2026-03-05-pyfiglet-guide","blog",false,"","Pyfiglet 使用教程","Pyfiglet ASCII艺术字生成教程，将普通文本转换为Banner、支持多种字体样式、对齐方式与颜色输出。","2026-03-05",[12,13],"Python","终端",{"type":15,"children":16,"toc":1068},"root",[17,26,30,36,42,67,73,76,82,116,122,148,154,157,163,204,209,258,264,286,290,346,352,355,361,399,403,467,473,496,502,525,531,534,540,570,576,619,633,639,642,648,718,724,778,784,789,835,841,844,850,868,874,895,926,932,986,992,1023,1029,1034,1057,1062],{"type":18,"tag":19,"props":20,"children":22},"element","h2",{"id":21},"一pyfiglet-简介",[23],{"type":24,"value":25},"text","一、Pyfiglet 简介",{"type":18,"tag":27,"props":28,"children":29},"hr",{},[],{"type":18,"tag":31,"props":32,"children":33},"p",{},[34],{"type":24,"value":35},"Pyfiglet 是一个 Python 模块，用于将普通文本转换为 ASCII 艺术字（大型字母）。它是 FIGlet 程序的 Python 实现，可以生成各种风格的文本 banner。",{"type":18,"tag":37,"props":38,"children":40},"h3",{"id":39},"主要特点",[41],{"type":24,"value":39},{"type":18,"tag":43,"props":44,"children":45},"ul",{},[46,52,57,62],{"type":18,"tag":47,"props":48,"children":49},"li",{},[50],{"type":24,"value":51},"支持多种字体样式",{"type":18,"tag":47,"props":53,"children":54},{},[55],{"type":24,"value":56},"可自定义输出宽度",{"type":18,"tag":47,"props":58,"children":59},{},[60],{"type":24,"value":61},"支持左右中对齐",{"type":18,"tag":47,"props":63,"children":64},{},[65],{"type":24,"value":66},"跨平台兼容",{"type":18,"tag":19,"props":68,"children":70},{"id":69},"二安装-pyfiglet",[71],{"type":24,"value":72},"二、安装 Pyfiglet",{"type":18,"tag":27,"props":74,"children":75},{},[],{"type":18,"tag":37,"props":77,"children":79},{"id":78},"_1-使用-pip-安装",[80],{"type":24,"value":81},"1. 使用 pip 安装",{"type":18,"tag":83,"props":84,"children":88},"pre",{"className":85,"code":86,"language":87,"meta":7,"style":7},"language-bash shiki shiki-themes github-dark","pip install pyfiglet\n","bash",[89],{"type":18,"tag":90,"props":91,"children":92},"code",{"__ignoreMap":7},[93],{"type":18,"tag":94,"props":95,"children":98},"span",{"class":96,"line":97},"line",1,[99,105,111],{"type":18,"tag":94,"props":100,"children":102},{"style":101},"--shiki-default:#B392F0",[103],{"type":24,"value":104},"pip",{"type":18,"tag":94,"props":106,"children":108},{"style":107},"--shiki-default:#9ECBFF",[109],{"type":24,"value":110}," install",{"type":18,"tag":94,"props":112,"children":113},{"style":107},[114],{"type":24,"value":115}," pyfiglet\n",{"type":18,"tag":37,"props":117,"children":119},{"id":118},"_2-验证安装",[120],{"type":24,"value":121},"2. 验证安装",{"type":18,"tag":83,"props":123,"children":127},{"className":124,"code":125,"language":126,"meta":7,"style":7},"language-python shiki shiki-themes github-dark","import pyfiglet\nprint(pyfiglet.__version__)\n","python",[128],{"type":18,"tag":90,"props":129,"children":130},{"__ignoreMap":7},[131,139],{"type":18,"tag":94,"props":132,"children":133},{"class":96,"line":97},[134],{"type":18,"tag":94,"props":135,"children":136},{},[137],{"type":24,"value":138},"import pyfiglet\n",{"type":18,"tag":94,"props":140,"children":142},{"class":96,"line":141},2,[143],{"type":18,"tag":94,"props":144,"children":145},{},[146],{"type":24,"value":147},"print(pyfiglet.__version__)\n",{"type":18,"tag":19,"props":149,"children":151},{"id":150},"三基本使用方法",[152],{"type":24,"value":153},"三、基本使用方法",{"type":18,"tag":27,"props":155,"children":156},{},[],{"type":18,"tag":37,"props":158,"children":160},{"id":159},"_1-最简单的文本转换",[161],{"type":24,"value":162},"1. 最简单的文本转换",{"type":18,"tag":83,"props":164,"children":166},{"className":124,"code":165,"language":126,"meta":7,"style":7},"import pyfiglet\n\nresult = pyfiglet.figlet_format(\"Hello\")\nprint(result)\n",[167],{"type":18,"tag":90,"props":168,"children":169},{"__ignoreMap":7},[170,177,186,195],{"type":18,"tag":94,"props":171,"children":172},{"class":96,"line":97},[173],{"type":18,"tag":94,"props":174,"children":175},{},[176],{"type":24,"value":138},{"type":18,"tag":94,"props":178,"children":179},{"class":96,"line":141},[180],{"type":18,"tag":94,"props":181,"children":183},{"emptyLinePlaceholder":182},true,[184],{"type":24,"value":185},"\n",{"type":18,"tag":94,"props":187,"children":189},{"class":96,"line":188},3,[190],{"type":18,"tag":94,"props":191,"children":192},{},[193],{"type":24,"value":194},"result = pyfiglet.figlet_format(\"Hello\")\n",{"type":18,"tag":94,"props":196,"children":198},{"class":96,"line":197},4,[199],{"type":18,"tag":94,"props":200,"children":201},{},[202],{"type":24,"value":203},"print(result)\n",{"type":18,"tag":31,"props":205,"children":206},{},[207],{"type":24,"value":208},"输出:",{"type":18,"tag":83,"props":210,"children":213},{"className":211,"code":212,"language":24,"meta":7,"style":7},"language-text shiki shiki-themes github-dark","  _   _      _ _       \n | | | | ___| | | ___  \n | |_| |\u002F _ \\ | |\u002F _ \\ \n |  _  |  __\u002F | | (_) |\n |_| |_|\\___|_|_|\\___\u002F \n",[214],{"type":18,"tag":90,"props":215,"children":216},{"__ignoreMap":7},[217,225,233,241,249],{"type":18,"tag":94,"props":218,"children":219},{"class":96,"line":97},[220],{"type":18,"tag":94,"props":221,"children":222},{},[223],{"type":24,"value":224},"  _   _      _ _       \n",{"type":18,"tag":94,"props":226,"children":227},{"class":96,"line":141},[228],{"type":18,"tag":94,"props":229,"children":230},{},[231],{"type":24,"value":232}," | | | | ___| | | ___  \n",{"type":18,"tag":94,"props":234,"children":235},{"class":96,"line":188},[236],{"type":18,"tag":94,"props":237,"children":238},{},[239],{"type":24,"value":240}," | |_| |\u002F _ \\ | |\u002F _ \\ \n",{"type":18,"tag":94,"props":242,"children":243},{"class":96,"line":197},[244],{"type":18,"tag":94,"props":245,"children":246},{},[247],{"type":24,"value":248}," |  _  |  __\u002F | | (_) |\n",{"type":18,"tag":94,"props":250,"children":252},{"class":96,"line":251},5,[253],{"type":18,"tag":94,"props":254,"children":255},{},[256],{"type":24,"value":257}," |_| |_|\\___|_|_|\\___\u002F\n",{"type":18,"tag":37,"props":259,"children":261},{"id":260},"_2-指定字体",[262],{"type":24,"value":263},"2. 指定字体",{"type":18,"tag":83,"props":265,"children":267},{"className":124,"code":266,"language":126,"meta":7,"style":7},"result = pyfiglet.figlet_format(\"Python\", font=\"slant\")\nprint(result)\n",[268],{"type":18,"tag":90,"props":269,"children":270},{"__ignoreMap":7},[271,279],{"type":18,"tag":94,"props":272,"children":273},{"class":96,"line":97},[274],{"type":18,"tag":94,"props":275,"children":276},{},[277],{"type":24,"value":278},"result = pyfiglet.figlet_format(\"Python\", font=\"slant\")\n",{"type":18,"tag":94,"props":280,"children":281},{"class":96,"line":141},[282],{"type":18,"tag":94,"props":283,"children":284},{},[285],{"type":24,"value":203},{"type":18,"tag":31,"props":287,"children":288},{},[289],{"type":24,"value":208},{"type":18,"tag":83,"props":291,"children":293},{"className":211,"code":292,"language":24,"meta":7,"style":7}," ____        _   _                 \n|  _ \\ _   _| |_| |__   ___  _ __  \n| |_) | | | | __| '_ \\ \u002F _ \\| '_ \\ \n|  __\u002F| |_| | |_| | | | (_) | | | |\n|_|    \\__, |\\__|_| |_|\\___\u002F|_| |_|\n       |___\u002F        \n",[294],{"type":18,"tag":90,"props":295,"children":296},{"__ignoreMap":7},[297,305,313,321,329,337],{"type":18,"tag":94,"props":298,"children":299},{"class":96,"line":97},[300],{"type":18,"tag":94,"props":301,"children":302},{},[303],{"type":24,"value":304}," ____        _   _                 \n",{"type":18,"tag":94,"props":306,"children":307},{"class":96,"line":141},[308],{"type":18,"tag":94,"props":309,"children":310},{},[311],{"type":24,"value":312},"|  _ \\ _   _| |_| |__   ___  _ __  \n",{"type":18,"tag":94,"props":314,"children":315},{"class":96,"line":188},[316],{"type":18,"tag":94,"props":317,"children":318},{},[319],{"type":24,"value":320},"| |_) | | | | __| '_ \\ \u002F _ \\| '_ \\ \n",{"type":18,"tag":94,"props":322,"children":323},{"class":96,"line":197},[324],{"type":18,"tag":94,"props":325,"children":326},{},[327],{"type":24,"value":328},"|  __\u002F| |_| | |_| | | | (_) | | | |\n",{"type":18,"tag":94,"props":330,"children":331},{"class":96,"line":251},[332],{"type":18,"tag":94,"props":333,"children":334},{},[335],{"type":24,"value":336},"|_|    \\__, |\\__|_| |_|\\___\u002F|_| |_|\n",{"type":18,"tag":94,"props":338,"children":340},{"class":96,"line":339},6,[341],{"type":18,"tag":94,"props":342,"children":343},{},[344],{"type":24,"value":345},"       |___\u002F\n",{"type":18,"tag":19,"props":347,"children":349},{"id":348},"四高级功能",[350],{"type":24,"value":351},"四、高级功能",{"type":18,"tag":27,"props":353,"children":354},{},[],{"type":18,"tag":37,"props":356,"children":358},{"id":357},"_1-使用-figlet-类",[359],{"type":24,"value":360},"1. 使用 Figlet 类",{"type":18,"tag":83,"props":362,"children":364},{"className":124,"code":363,"language":126,"meta":7,"style":7},"from pyfiglet import Figlet\n\nf = Figlet(font='banner')\nprint(f.renderText('Advanced'))\n",[365],{"type":18,"tag":90,"props":366,"children":367},{"__ignoreMap":7},[368,376,383,391],{"type":18,"tag":94,"props":369,"children":370},{"class":96,"line":97},[371],{"type":18,"tag":94,"props":372,"children":373},{},[374],{"type":24,"value":375},"from pyfiglet import Figlet\n",{"type":18,"tag":94,"props":377,"children":378},{"class":96,"line":141},[379],{"type":18,"tag":94,"props":380,"children":381},{"emptyLinePlaceholder":182},[382],{"type":24,"value":185},{"type":18,"tag":94,"props":384,"children":385},{"class":96,"line":188},[386],{"type":18,"tag":94,"props":387,"children":388},{},[389],{"type":24,"value":390},"f = Figlet(font='banner')\n",{"type":18,"tag":94,"props":392,"children":393},{"class":96,"line":197},[394],{"type":18,"tag":94,"props":395,"children":396},{},[397],{"type":24,"value":398},"print(f.renderText('Advanced'))\n",{"type":18,"tag":31,"props":400,"children":401},{},[402],{"type":24,"value":208},{"type":18,"tag":83,"props":404,"children":406},{"className":211,"code":405,"language":24,"meta":7,"style":7},"     #     #    #    ######  ####### \n     #     #   # #   #     # #     # \n     #     #  #   #  #     # #     # \n     #     # #     # ######  #     # \n      #   #  ####### #       #     # \n       # #   #     # #       #     # \n        #    #     # #       ####### \n",[407],{"type":18,"tag":90,"props":408,"children":409},{"__ignoreMap":7},[410,418,426,434,442,450,458],{"type":18,"tag":94,"props":411,"children":412},{"class":96,"line":97},[413],{"type":18,"tag":94,"props":414,"children":415},{},[416],{"type":24,"value":417},"     #     #    #    ######  ####### \n",{"type":18,"tag":94,"props":419,"children":420},{"class":96,"line":141},[421],{"type":18,"tag":94,"props":422,"children":423},{},[424],{"type":24,"value":425},"     #     #   # #   #     # #     # \n",{"type":18,"tag":94,"props":427,"children":428},{"class":96,"line":188},[429],{"type":18,"tag":94,"props":430,"children":431},{},[432],{"type":24,"value":433},"     #     #  #   #  #     # #     # \n",{"type":18,"tag":94,"props":435,"children":436},{"class":96,"line":197},[437],{"type":18,"tag":94,"props":438,"children":439},{},[440],{"type":24,"value":441},"     #     # #     # ######  #     # \n",{"type":18,"tag":94,"props":443,"children":444},{"class":96,"line":251},[445],{"type":18,"tag":94,"props":446,"children":447},{},[448],{"type":24,"value":449},"      #   #  ####### #       #     # \n",{"type":18,"tag":94,"props":451,"children":452},{"class":96,"line":339},[453],{"type":18,"tag":94,"props":454,"children":455},{},[456],{"type":24,"value":457},"       # #   #     # #       #     # \n",{"type":18,"tag":94,"props":459,"children":461},{"class":96,"line":460},7,[462],{"type":18,"tag":94,"props":463,"children":464},{},[465],{"type":24,"value":466},"        #    #     # #       #######\n",{"type":18,"tag":37,"props":468,"children":470},{"id":469},"_2-设置输出宽度",[471],{"type":24,"value":472},"2. 设置输出宽度",{"type":18,"tag":83,"props":474,"children":476},{"className":124,"code":475,"language":126,"meta":7,"style":7},"f = Figlet(font='standard', width=100)\nprint(f.renderText('Wide Text'))\n",[477],{"type":18,"tag":90,"props":478,"children":479},{"__ignoreMap":7},[480,488],{"type":18,"tag":94,"props":481,"children":482},{"class":96,"line":97},[483],{"type":18,"tag":94,"props":484,"children":485},{},[486],{"type":24,"value":487},"f = Figlet(font='standard', width=100)\n",{"type":18,"tag":94,"props":489,"children":490},{"class":96,"line":141},[491],{"type":18,"tag":94,"props":492,"children":493},{},[494],{"type":24,"value":495},"print(f.renderText('Wide Text'))\n",{"type":18,"tag":37,"props":497,"children":499},{"id":498},"_3-文本对齐方式",[500],{"type":24,"value":501},"3. 文本对齐方式",{"type":18,"tag":83,"props":503,"children":505},{"className":124,"code":504,"language":126,"meta":7,"style":7},"f = Figlet(font='small', justify='center')  # 可选 'left', 'center', 'right'\nprint(f.renderText('Centered'))\n",[506],{"type":18,"tag":90,"props":507,"children":508},{"__ignoreMap":7},[509,517],{"type":18,"tag":94,"props":510,"children":511},{"class":96,"line":97},[512],{"type":18,"tag":94,"props":513,"children":514},{},[515],{"type":24,"value":516},"f = Figlet(font='small', justify='center')  # 可选 'left', 'center', 'right'\n",{"type":18,"tag":94,"props":518,"children":519},{"class":96,"line":141},[520],{"type":18,"tag":94,"props":521,"children":522},{},[523],{"type":24,"value":524},"print(f.renderText('Centered'))\n",{"type":18,"tag":19,"props":526,"children":528},{"id":527},"五字体管理",[529],{"type":24,"value":530},"五、字体管理",{"type":18,"tag":27,"props":532,"children":533},{},[],{"type":18,"tag":37,"props":535,"children":537},{"id":536},"_1-获取可用字体列表",[538],{"type":24,"value":539},"1. 获取可用字体列表",{"type":18,"tag":83,"props":541,"children":543},{"className":124,"code":542,"language":126,"meta":7,"style":7},"from pyfiglet import FigletFont\n\nprint(FigletFont.getFonts())\n",[544],{"type":18,"tag":90,"props":545,"children":546},{"__ignoreMap":7},[547,555,562],{"type":18,"tag":94,"props":548,"children":549},{"class":96,"line":97},[550],{"type":18,"tag":94,"props":551,"children":552},{},[553],{"type":24,"value":554},"from pyfiglet import FigletFont\n",{"type":18,"tag":94,"props":556,"children":557},{"class":96,"line":141},[558],{"type":18,"tag":94,"props":559,"children":560},{"emptyLinePlaceholder":182},[561],{"type":24,"value":185},{"type":18,"tag":94,"props":563,"children":564},{"class":96,"line":188},[565],{"type":18,"tag":94,"props":566,"children":567},{},[568],{"type":24,"value":569},"print(FigletFont.getFonts())\n",{"type":18,"tag":37,"props":571,"children":573},{"id":572},"_2-使用自定义字体",[574],{"type":24,"value":575},"2. 使用自定义字体",{"type":18,"tag":577,"props":578,"children":579},"ol",{},[580,593,614],{"type":18,"tag":47,"props":581,"children":582},{},[583,585,591],{"type":24,"value":584},"首先获取字体文件 (",{"type":18,"tag":90,"props":586,"children":588},{"className":587},[],[589],{"type":24,"value":590},".flf",{"type":24,"value":592},")",{"type":18,"tag":47,"props":594,"children":595},{},[596,598,604,606,612],{"type":24,"value":597},"将字体文件放在",{"type":18,"tag":90,"props":599,"children":601},{"className":600},[],[602],{"type":24,"value":603}," pyfiglet",{"type":24,"value":605}," 的 ",{"type":18,"tag":90,"props":607,"children":609},{"className":608},[],[610],{"type":24,"value":611},"fonts",{"type":24,"value":613}," 目录或指定路径",{"type":18,"tag":47,"props":615,"children":616},{},[617],{"type":24,"value":618},"使用字体:",{"type":18,"tag":83,"props":620,"children":622},{"className":124,"code":621,"language":126,"meta":7,"style":7},"f = Figlet(font='path\u002Fto\u002Fcustom.flf')\n",[623],{"type":18,"tag":90,"props":624,"children":625},{"__ignoreMap":7},[626],{"type":18,"tag":94,"props":627,"children":628},{"class":96,"line":97},[629],{"type":18,"tag":94,"props":630,"children":631},{},[632],{"type":24,"value":621},{"type":18,"tag":19,"props":634,"children":636},{"id":635},"六实用示例",[637],{"type":24,"value":638},"六、实用示例",{"type":18,"tag":27,"props":640,"children":641},{},[],{"type":18,"tag":37,"props":643,"children":645},{"id":644},"_1-创建欢迎横幅",[646],{"type":24,"value":647},"1. 创建欢迎横幅",{"type":18,"tag":83,"props":649,"children":651},{"className":124,"code":650,"language":126,"meta":7,"style":7},"def welcome_banner():\n    f = Figlet(font='big', width=120)\n    print(f.renderText('WELCOME'))\n    print(\"-\" * 80)\n    print(\" Welcome to our Python application!\".center(80))\n    print(\"-\" * 80)\n\nwelcome_banner()\n",[652],{"type":18,"tag":90,"props":653,"children":654},{"__ignoreMap":7},[655,663,671,679,687,695,702,709],{"type":18,"tag":94,"props":656,"children":657},{"class":96,"line":97},[658],{"type":18,"tag":94,"props":659,"children":660},{},[661],{"type":24,"value":662},"def welcome_banner():\n",{"type":18,"tag":94,"props":664,"children":665},{"class":96,"line":141},[666],{"type":18,"tag":94,"props":667,"children":668},{},[669],{"type":24,"value":670},"    f = Figlet(font='big', width=120)\n",{"type":18,"tag":94,"props":672,"children":673},{"class":96,"line":188},[674],{"type":18,"tag":94,"props":675,"children":676},{},[677],{"type":24,"value":678},"    print(f.renderText('WELCOME'))\n",{"type":18,"tag":94,"props":680,"children":681},{"class":96,"line":197},[682],{"type":18,"tag":94,"props":683,"children":684},{},[685],{"type":24,"value":686},"    print(\"-\" * 80)\n",{"type":18,"tag":94,"props":688,"children":689},{"class":96,"line":251},[690],{"type":18,"tag":94,"props":691,"children":692},{},[693],{"type":24,"value":694},"    print(\" Welcome to our Python application!\".center(80))\n",{"type":18,"tag":94,"props":696,"children":697},{"class":96,"line":339},[698],{"type":18,"tag":94,"props":699,"children":700},{},[701],{"type":24,"value":686},{"type":18,"tag":94,"props":703,"children":704},{"class":96,"line":460},[705],{"type":18,"tag":94,"props":706,"children":707},{"emptyLinePlaceholder":182},[708],{"type":24,"value":185},{"type":18,"tag":94,"props":710,"children":712},{"class":96,"line":711},8,[713],{"type":18,"tag":94,"props":714,"children":715},{},[716],{"type":24,"value":717},"welcome_banner()\n",{"type":18,"tag":37,"props":719,"children":721},{"id":720},"_2-进度指示器",[722],{"type":24,"value":723},"2. 进度指示器",{"type":18,"tag":83,"props":725,"children":727},{"className":124,"code":726,"language":126,"meta":7,"style":7},"import time\n\nfor i in range(1, 6):\n    text = f\"STEP {i}\"\n    print(pyfiglet.figlet_format(text, font=\"mini\"))\n    time.sleep(1)\n",[728],{"type":18,"tag":90,"props":729,"children":730},{"__ignoreMap":7},[731,739,746,754,762,770],{"type":18,"tag":94,"props":732,"children":733},{"class":96,"line":97},[734],{"type":18,"tag":94,"props":735,"children":736},{},[737],{"type":24,"value":738},"import time\n",{"type":18,"tag":94,"props":740,"children":741},{"class":96,"line":141},[742],{"type":18,"tag":94,"props":743,"children":744},{"emptyLinePlaceholder":182},[745],{"type":24,"value":185},{"type":18,"tag":94,"props":747,"children":748},{"class":96,"line":188},[749],{"type":18,"tag":94,"props":750,"children":751},{},[752],{"type":24,"value":753},"for i in range(1, 6):\n",{"type":18,"tag":94,"props":755,"children":756},{"class":96,"line":197},[757],{"type":18,"tag":94,"props":758,"children":759},{},[760],{"type":24,"value":761},"    text = f\"STEP {i}\"\n",{"type":18,"tag":94,"props":763,"children":764},{"class":96,"line":251},[765],{"type":18,"tag":94,"props":766,"children":767},{},[768],{"type":24,"value":769},"    print(pyfiglet.figlet_format(text, font=\"mini\"))\n",{"type":18,"tag":94,"props":771,"children":772},{"class":96,"line":339},[773],{"type":18,"tag":94,"props":774,"children":775},{},[776],{"type":24,"value":777},"    time.sleep(1)\n",{"type":18,"tag":37,"props":779,"children":781},{"id":780},"_3-彩色-ascii-艺术字",[782],{"type":24,"value":783},"3. 彩色 ASCII 艺术字",{"type":18,"tag":31,"props":785,"children":786},{},[787],{"type":24,"value":788},"结合 colorama 模块:",{"type":18,"tag":83,"props":790,"children":792},{"className":124,"code":791,"language":126,"meta":7,"style":7},"from colorama import Fore, init\ninit()\n\nresult = pyfiglet.figlet_format(\"COLOR\", font=\"slant\")\nprint(Fore.RED + result)\n",[793],{"type":18,"tag":90,"props":794,"children":795},{"__ignoreMap":7},[796,804,812,819,827],{"type":18,"tag":94,"props":797,"children":798},{"class":96,"line":97},[799],{"type":18,"tag":94,"props":800,"children":801},{},[802],{"type":24,"value":803},"from colorama import Fore, init\n",{"type":18,"tag":94,"props":805,"children":806},{"class":96,"line":141},[807],{"type":18,"tag":94,"props":808,"children":809},{},[810],{"type":24,"value":811},"init()\n",{"type":18,"tag":94,"props":813,"children":814},{"class":96,"line":188},[815],{"type":18,"tag":94,"props":816,"children":817},{"emptyLinePlaceholder":182},[818],{"type":24,"value":185},{"type":18,"tag":94,"props":820,"children":821},{"class":96,"line":197},[822],{"type":18,"tag":94,"props":823,"children":824},{},[825],{"type":24,"value":826},"result = pyfiglet.figlet_format(\"COLOR\", font=\"slant\")\n",{"type":18,"tag":94,"props":828,"children":829},{"class":96,"line":251},[830],{"type":18,"tag":94,"props":831,"children":832},{},[833],{"type":24,"value":834},"print(Fore.RED + result)\n",{"type":18,"tag":19,"props":836,"children":838},{"id":837},"七常见问题解答",[839],{"type":24,"value":840},"七、常见问题解答",{"type":18,"tag":27,"props":842,"children":843},{},[],{"type":18,"tag":37,"props":845,"children":847},{"id":846},"_1-字体显示不正常",[848],{"type":24,"value":849},"1. 字体显示不正常",{"type":18,"tag":43,"props":851,"children":852},{},[853,858,863],{"type":18,"tag":47,"props":854,"children":855},{},[856],{"type":24,"value":857},"确保终端支持 ASCII 艺术字",{"type":18,"tag":47,"props":859,"children":860},{},[861],{"type":24,"value":862},"尝试不同的字体",{"type":18,"tag":47,"props":864,"children":865},{},[866],{"type":24,"value":867},"检查终端字体设置",{"type":18,"tag":37,"props":869,"children":871},{"id":870},"_2-如何调整字符间距",[872],{"type":24,"value":873},"2. 如何调整字符间距",{"type":18,"tag":31,"props":875,"children":876},{},[877,879,885,887,893],{"type":24,"value":878},"使用 ",{"type":18,"tag":90,"props":880,"children":882},{"className":881},[],[883],{"type":24,"value":884},"Figlet",{"type":24,"value":886}," 类的 ",{"type":18,"tag":90,"props":888,"children":890},{"className":889},[],[891],{"type":24,"value":892},"setFont()",{"type":24,"value":894}," 方法:",{"type":18,"tag":83,"props":896,"children":898},{"className":124,"code":897,"language":126,"meta":7,"style":7},"f = Figlet()\nf.setFont(font='term', kwidth=2)  # 增加字符间距\nprint(f.renderText('Spaced'))\n",[899],{"type":18,"tag":90,"props":900,"children":901},{"__ignoreMap":7},[902,910,918],{"type":18,"tag":94,"props":903,"children":904},{"class":96,"line":97},[905],{"type":18,"tag":94,"props":906,"children":907},{},[908],{"type":24,"value":909},"f = Figlet()\n",{"type":18,"tag":94,"props":911,"children":912},{"class":96,"line":141},[913],{"type":18,"tag":94,"props":914,"children":915},{},[916],{"type":24,"value":917},"f.setFont(font='term', kwidth=2)  # 增加字符间距\n",{"type":18,"tag":94,"props":919,"children":920},{"class":96,"line":188},[921],{"type":18,"tag":94,"props":922,"children":923},{},[924],{"type":24,"value":925},"print(f.renderText('Spaced'))\n",{"type":18,"tag":37,"props":927,"children":929},{"id":928},"_3-多行文本处理",[930],{"type":24,"value":931},"3. 多行文本处理",{"type":18,"tag":83,"props":933,"children":935},{"className":124,"code":934,"language":126,"meta":7,"style":7},"text = \"\"\"Line 1\nLine 2\nLine 3\"\"\"\n\nfor line in text.split('\\n'):\n    print(pyfiglet.figlet_format(line, font=\"small\"))\n",[936],{"type":18,"tag":90,"props":937,"children":938},{"__ignoreMap":7},[939,947,955,963,970,978],{"type":18,"tag":94,"props":940,"children":941},{"class":96,"line":97},[942],{"type":18,"tag":94,"props":943,"children":944},{},[945],{"type":24,"value":946},"text = \"\"\"Line 1\n",{"type":18,"tag":94,"props":948,"children":949},{"class":96,"line":141},[950],{"type":18,"tag":94,"props":951,"children":952},{},[953],{"type":24,"value":954},"Line 2\n",{"type":18,"tag":94,"props":956,"children":957},{"class":96,"line":188},[958],{"type":18,"tag":94,"props":959,"children":960},{},[961],{"type":24,"value":962},"Line 3\"\"\"\n",{"type":18,"tag":94,"props":964,"children":965},{"class":96,"line":197},[966],{"type":18,"tag":94,"props":967,"children":968},{"emptyLinePlaceholder":182},[969],{"type":24,"value":185},{"type":18,"tag":94,"props":971,"children":972},{"class":96,"line":251},[973],{"type":18,"tag":94,"props":974,"children":975},{},[976],{"type":24,"value":977},"for line in text.split('\\n'):\n",{"type":18,"tag":94,"props":979,"children":980},{"class":96,"line":339},[981],{"type":18,"tag":94,"props":982,"children":983},{},[984],{"type":24,"value":985},"    print(pyfiglet.figlet_format(line, font=\"small\"))\n",{"type":18,"tag":19,"props":987,"children":989},{"id":988},"八最佳实践",[990],{"type":24,"value":991},"八、最佳实践",{"type":18,"tag":577,"props":993,"children":994},{},[995,1000,1013,1018],{"type":18,"tag":47,"props":996,"children":997},{},[998],{"type":24,"value":999},"对于长文本，考虑使用较简单的字体",{"type":18,"tag":47,"props":1001,"children":1002},{},[1003,1005,1011],{"type":24,"value":1004},"在 Web 应用中，可以将输出转换为 HTML 的 ",{"type":18,"tag":90,"props":1006,"children":1008},{"className":1007},[],[1009],{"type":24,"value":1010},"\u003Cpre>",{"type":24,"value":1012}," 标签",{"type":18,"tag":47,"props":1014,"children":1015},{},[1016],{"type":24,"value":1017},"日志系统中可以使用 ASCII banner 分隔不同部分",{"type":18,"tag":47,"props":1019,"children":1020},{},[1021],{"type":24,"value":1022},"结合进度条库创建更丰富的终端界面",{"type":18,"tag":19,"props":1024,"children":1026},{"id":1025},"九总结",[1027],{"type":24,"value":1028},"九、总结",{"type":18,"tag":31,"props":1030,"children":1031},{},[1032],{"type":24,"value":1033},"Pyfiglet 是一个功能强大且易于使用的 ASCII 艺术字生成工具，适用于:",{"type":18,"tag":43,"props":1035,"children":1036},{},[1037,1042,1047,1052],{"type":18,"tag":47,"props":1038,"children":1039},{},[1040],{"type":24,"value":1041},"命令行工具美化",{"type":18,"tag":47,"props":1043,"children":1044},{},[1045],{"type":24,"value":1046},"日志系统装饰",{"type":18,"tag":47,"props":1048,"children":1049},{},[1050],{"type":24,"value":1051},"终端应用界面",{"type":18,"tag":47,"props":1053,"children":1054},{},[1055],{"type":24,"value":1056},"生成独特的文本输出",{"type":18,"tag":31,"props":1058,"children":1059},{},[1060],{"type":24,"value":1061},"通过本教程，掌握了 Pyfiglet 的基本和高级用法，可以开始在项目中应用这些技术了。",{"type":18,"tag":1063,"props":1064,"children":1065},"style",{},[1066],{"type":24,"value":1067},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":7,"searchDepth":141,"depth":141,"links":1069},[1070,1073,1077,1081,1086,1090,1095,1100,1101],{"id":21,"depth":141,"text":25,"children":1071},[1072],{"id":39,"depth":188,"text":39},{"id":69,"depth":141,"text":72,"children":1074},[1075,1076],{"id":78,"depth":188,"text":81},{"id":118,"depth":188,"text":121},{"id":150,"depth":141,"text":153,"children":1078},[1079,1080],{"id":159,"depth":188,"text":162},{"id":260,"depth":188,"text":263},{"id":348,"depth":141,"text":351,"children":1082},[1083,1084,1085],{"id":357,"depth":188,"text":360},{"id":469,"depth":188,"text":472},{"id":498,"depth":188,"text":501},{"id":527,"depth":141,"text":530,"children":1087},[1088,1089],{"id":536,"depth":188,"text":539},{"id":572,"depth":188,"text":575},{"id":635,"depth":141,"text":638,"children":1091},[1092,1093,1094],{"id":644,"depth":188,"text":647},{"id":720,"depth":188,"text":723},{"id":780,"depth":188,"text":783},{"id":837,"depth":141,"text":840,"children":1096},[1097,1098,1099],{"id":846,"depth":188,"text":849},{"id":870,"depth":188,"text":873},{"id":928,"depth":188,"text":931},{"id":988,"depth":141,"text":991},{"id":1025,"depth":141,"text":1028},"markdown","content:blog:2026-03-05-pyfiglet-guide.md","content","blog\u002F2026-03-05-pyfiglet-guide.md","blog\u002F2026-03-05-pyfiglet-guide","md",1780801017580]