Python Can';t使用变量来定义枕头的颜色

Python Can';t使用变量来定义枕头的颜色,python,colors,pillow,Python,Colors,Pillow,我在使用枕头时犯了一个小错误。我试图用变量设置文本的颜色,但得到一个ValueError:未知的颜色说明符:“'232,43123255””。 这是我的密码: header = Image.open("A.png") couleur_Ellipse = "rose" draw = ImageDraw.Draw(header) point = ( int(header.width * 0.780), int(header.height * 0.68)) header.paste(ellipse,

我在使用枕头时犯了一个小错误。我试图用变量设置文本的颜色,但得到一个ValueError:未知的颜色说明符:“'232,43123255””。 这是我的密码:

header = Image.open("A.png")
couleur_Ellipse = "rose"
draw = ImageDraw.Draw(header)
point = ( int(header.width * 0.780), int(header.height * 0.68))
header.paste(ellipse, point, ellipse)
colortext = '"232,43,123,255"'
pointtext1 = ( int(header.width * 0.845), int(header.height * 0.75))
pointtext2 = ( int(header.width * 0.798), int(header.height * 0.79))
draw.text(pointtext1, "this is some text", font=ImageFont.truetype("C:\Windows\Fonts\Arial.ttf", 14), fill=colortext)
draw.text(pointtext2, "some other text", font=ImageFont.truetype("C:\Windows\Fonts\\arialbd.ttf", 55), fill=colortext)
header.save('Images/header ' + couleur_Ellipse + '.png')

有什么见解吗?我不明白为什么它不起作用

将评论转换为答案:

cf:

根据文档,您需要提供颜色函数(或十六进制颜色),而不仅仅是一串值。而且,作为字符串提供的颜色函数似乎不支持alpha值

试试这个:

colortext = "rgb(232,43,123)"

将评论转换为答案:

cf:

根据文档,您需要提供颜色函数(或十六进制颜色),而不仅仅是一串值。而且,作为字符串提供的颜色函数似乎不支持alpha值

试试这个:

colortext = "rgb(232,43,123)"

似乎您需要提供一个颜色函数,而不仅仅是一个值字符串。我还假设您使用的PIL版本等于或大于1.1.4,以便提供alpha值?试着不用alpha:colortext=“rgb(232,43123)”它就可以了!谢谢。我不是以英语为母语的人,所以文档对我来说总是有点难读。谢谢似乎您需要提供一个颜色函数,而不仅仅是一个值字符串。我还假设您使用的PIL版本等于或大于1.1.4,以便提供alpha值?试着不用alpha:colortext=“rgb(232,43123)”它就可以了!谢谢。我不是以英语为母语的人,所以文档对我来说总是有点难读。谢谢