import pyfiglet
from termcolor import colored
total_colors = ["red", "green", "yellow", "blue", "magenta", "cyan", "white"]
msg = input("What would you like to print? ")
col = input("what color?")
if col not in total_colors:
col = "green"
ascii_art = pyfiglet.figlet_format(msg)
colored_ascii = colored(ascii_art, color=col)
print(colored_ascii)
ImportError: cannot import name 'figlet_format' from 'pyfiglet'
我知道这听起来很明显,但请确保在您的计算机上安装了lib。如果是,请确保将lib安装在Python的安装位置
我在你的节目中看到了一些问题
1.安装pyfiglet模块
pip install pyfiglet
2.
msg = input("What would you like to print? ")
不需要在这一行输入,因为下一行接受输入,程序的逻辑基于下一个输入
3.
ascii_art = pyfiglet.figlet_format(msg) colored_ascii = colored(ascii_art, color=col) print(colored_ascii)
上面的一行应该是
ascii_art = pyfiglet.figlet_format(col) colored_ascii = colored(ascii_art, color=col) print(colored_ascii)
我安装了pyfiglet模块并实现了修改后的程序
输出:
相关问题 更多 >
编程相关推荐