【发布时间】:2018-10-31 18:45:40
【问题描述】:
我在 Python 代码中定义了一个列表。
list = ['kumar','satheesh','rajan']
BOLD = '\033[1m'
for i, item in enumerate(list):
list[i] = BOLD + item
print (list)
但我收到了output as ['\x1b[1mfsdfs', '\x1b[1mfsdfsd', '\x1b[1mgdfdf']
但所需的输出是['kumar','satheesh','rajan']
如何在bold 中使用pythonlist elements list elements?
【问题讨论】:
-
请考虑为您的列表使用不同的变量名.. list 不是强制关键字,但如果您将其用作变量名,它会给您带来无法预料的问题..
-
如果真的想在打印数组之前打印粗体,您也在为方括号制作粗体
标签: python console ansi output-formatting