我已经安装了这个python模块 https://pypi.python.org/pypi/termcolor
使用链接中提供的示例,我尝试以不同的方式打印字符串,如下所示:
from termcolor import colored, cprint
text = colored(ship_row, 'red', attrs=['reverse', 'blink'])
print(text)
cprint(ship_row, 'green', 'on_red')
但是,我的输出是:
,而不是使用所需的颜色打印字符串[5m[7m[31m3[0m
[41m[32m3[0m
有谁知道如何解决这个问题?
答案 0 :(得分:0)
您需要为colorcolor导入colorama才能在Windows终端上使用
function pie(x1, y1, x2, y2, x3, y3, x4, y4)
{
// ... rest of function is the same as arc() ...
return ['M', xCentre, yCentre,
'L', xCentre + startpt.x, yCentre + startpt.y,
'A', xRadius, yRadius, 0, largeArcFlag, 0, xCentre + endpt.x, yCentre + endpt.y,
'Z'].join(' ');
}