学习笔记,学习python时碰到的小问题和解决方法

1、运行turtle库时使用red参数出现问题

NameError: name 'red' is not defined

原因,错误使用,没有添加引号:

turtle.color(red)

正确使用为:turtle.color('red')

2、turtle.color(r,g,b)调用出错

turtle.TurtleGraphicsError: bad color sequence: (100, 100, 100)

错误代码为:

turtle.color(100, 100, 100)

正确使用为:turtle.color(0.5,1,1),因为这里的r,g,b的参数代表的是百分比,使用超过1的会出现参数报错

猜你喜欢

转载自blog.csdn.net/weixin_42056625/article/details/86493185
今日推荐