首页 > 解决方案 > 如何打印彩色文本

问题描述

我的程序中有以下代码行,它执行得很好,没有问题,但是当我尝试稍微更改代码以打印彩色输出文本时,它不起作用。我确定这是一个语法问题,如果有人可以提供帮助,那就太好了

from termcolor import colored, cprint
print("Name of the table:",table)
print("printing all the column names of this table:\n", df1_columns.columns)
print("count number of columns in this table: ",len(df1_columns.columns))

我将上面的内容更改为以下内容并引发错误

print(colored("print name of the table:"),table,'blue')                                                                                           
print(colored("print all the column names of this table:\n",df1_columns.columns,'blue')   
print(colored("print number of columns in this table: ",len(df1_columns.columns,'blue'))

标签: pythonprintingtermcolor

解决方案


推荐阅读