Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python setFill(颜色rgb(100,x,0)-语法错误?_Python - Fatal编程技术网

Python setFill(颜色rgb(100,x,0)-语法错误?

Python setFill(颜色rgb(100,x,0)-语法错误?,python,Python,试图使用随机化变量随机化颜色?出现语法错误。这可能吗? 下面是代码的其余部分(如果有帮助的话): import graphics import random window= graphics.GraphWin("x", 600, 400) stripes = input("How many stripes should be on the flag") stripes = int(stripes) count = 0 count = int(count) P1=graphics.Point(0,

试图使用随机化变量随机化颜色?出现语法错误。这可能吗? 下面是代码的其余部分(如果有帮助的话):

import graphics
import random
window= graphics.GraphWin("x", 600, 400)
stripes = input("How many stripes should be on the flag")
stripes = int(stripes)
count = 0
count = int(count)
P1=graphics.Point(0,0) #left corner - anchor point
for x in range(stripes): #loop for division of flag
    col= random.randint(1,255)
    stepdim = 400/stripes #size of divisions
    shrink = count*stepdim
    stepdim = int(stepdim)
    stepdim = stepdim*10 #enlarge to an increment below the last
    stepdim = stepdim-shrink
    stepdim = int(stepdim)
    P2=graphics.Point(600,stepdim) #bottom right corner - ever shrinking
    outsiderec=graphics.Rectangle(P1,P2) #
    outsiderec.setFill(Color rgb(100, col, 0)
    outsiderec.draw(window)
    count= count + 1
    count= int(count)
window.getMouse()
window.close()
python 3.4,如果有帮助的话

要使用时,需要使用颜色rgb100,col,0而不是颜色rgb100,col,0


注意第一次导入颜色\u rgb:从图形导入颜色\u rgb

您需要关闭该行上的另一个括号。哇。@PakkuDon Bonehead错误,但在修复后它仍然持续存在。@Kasra是的。如果有任何帮助提供名称错误,我将发布错误图片。错误:名称“颜色\u rgb”未定义。exq…第一次导入颜色\u rgb!开始了。不汉克斯非常喜欢。