0

我想让用户输入一个颜色名称来设置乌龟窗口的背景,这是一个绘图程序,我忘记了怎么做?

import turtle

wn = turtle.Screen()


color = raw_input('enter background color') 

color ??????? wn.bgcolor('')      # set the window background color




tess = turtle.Turtle()
tess.color("blue")              # make tess blue
tess.pensize(3)                 # set the width of her pen

tess.forward(50)
tess.left(120)
tess.forward(50)

wn.exitonclick()                # wait for a user click on the canvas
4

1 回答 1

0

只需将字符串提供给bgcolor()方法:

...
color = raw_input('Enter background color: ')
wn.bgcolor(color)
tess = turtle.Turtle()
....
于 2013-11-15T04:58:52.033 回答