python - 如何打印彩色文本
问题描述
我的程序中有以下代码行,它执行得很好,没有问题,但是当我尝试稍微更改代码以打印彩色输出文本时,它不起作用。我确定这是一个语法问题,如果有人可以提供帮助,那就太好了
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'))
解决方案
推荐阅读
- json - 从scala中的字段生成一个json结构
- clojure - 在 mac os 10.13.6 下安装 clojure lein 的问题
- python - 如何在 python 中测试 Klein 服务器
- jquery - 使用 JQuery 插入 XML 将属性更改为小写
- java - 为什么当我修改原始 ArrayList 时复制的 ArrayList 会被修改
- c# - TCP C++ 客户端从 ac# 服务器接收字节数组
- ionic-framework - 离子应用程序的构建问题
- css - 获取内插字符串的值
- c# - 如何让客户收到他们填写的表格的副本,作为 ASP.NET + C# 中的 PDF
- react-native - React Native 与 Redux:mapStateToProps()-函数未更新