怎么了吗
不好意思,我英文填错了,老师,我自己找到问题了
ok
老师麻烦问一下啊,同样的代码,为什么颜色会影响到运行啊,填蓝色就运行报错,黄色就能正常运行
代码错误,认真核对代码
turtle.penup() turtle.goto(,) turtle.pendown() turtle.color() turtle.circle() turtle.done()
请问第三个圈程序跑不出来是怎么回事?
在你提供的代码片段中,有几个问题可能会导致程序无法正常运行或无法绘制出第三个圆:
1.goto() 函数中缺少坐标参数:在 turtle.goto() 函数中,缺少目标坐标参数。你需要提供目标坐标作为 (x, y) 对,以告诉海龟应该移动到哪个位置。
2.color() 函数中缺少颜色参数:在 turtle.color() 函数中,缺少要设置的颜色参数。你需要指定一个颜色作为参数,例如 "red"、"blue" 或 RGB 元组。
3.circle() 函数中缺少半径参数:在 turtle.circle() 函数中,缺少圆的半径参数。你需要指定一个半径来绘制一个圆。
import turtle # 创建 Turtle 对象 t = turtle.Turtle() # 第一个圆 t.penup() t.goto(-100, 0) t.pendown() t.color("red") t.circle(50) # 第二个圆 t.penup() t.goto(0, 0) t.pendown() t.color("green") t.circle(50) # 第三个圆 t.penup() t.goto(100, 0) t.pendown() t.color("blue") t.circle(50) # 结束绘图 turtle.done()
import turtle turtle.width(10) turtle.color("blue") turtle.circle(50) 点了运行右边的那个按钮,之后再运行就不行了 输入的这个,不行啊求老师解惑
右键 运行当前项目
再运行的情况下就那个turtle就变成蓝色的了,没办法调动数据库了,然后就显示运行错误,我重新卸载了python重新安装好像还不行
可以联系技术老师远程帮你看看
turtle turtle.width() turtle.color() turtle.circle()
报错AttributeError: module 'turtle' has no attribute 'width'
这个怎么解老师
点到右上角运行边上那个按钮之后就都这样了,重新删除重新创建也这样
这个是代码错误了
老师我点错了右上角运行旁边的debug
后续再运行就运行不了了显示:
AttributeError: module 'turtle' has no attribute 'width'
我编辑的
turtle turtle.width() turtle.color() turtle.circle()
怎么解
乱码了,代码内容重新发下吧
import turtle #第一个圈 turtle.width(10) turtle.color("blue") turtle.circle(50)
我这边运行不起来,还会弹出turtle.TurtleGraphicsError: bad color string: bule这样的代码,好像是蓝色不能用,我用红色就可以
英文不好
import turtle # 第一个圈 turtle.width(10) turtle.color("blue") turtle.circle(50)
import turtle #第一个圈 turtle.width(10) turtle.color("blue") turtle.circle(50) #第二个圈 turtle.penup() turtle.goto(80,0) turtle.pendown() turtle.circle(50) turtle.color("black") #第三个圈 turtle.penup() turtle.goto(160,0) turtle.pendown() turtle.color("red") turtle.circle(50) #第四个圈 turtle.penup() turtle.goto(40,-60) turtle.pendown() turtle.color("yelow") turtle.circle(50) #第五个圈 turtle.penup() turtle.goto(100,-60) turtle.pendown() turtle.color("green") turtle.circle(50) turtle.done
为什么当部分代码顺序发生变化时代码运行报错
这个抬笔落笔点是有位置要求的
import turtle #第一个圈 turtle.width(10) turtle.color("blue") turtle.circle(50) #第二个圈 turtle.penup() turtle.goto(80,0) turtle.pendown() turtle.color("black") turtle.circle(50) #第三个圈 turtle.penup() turtle.goto(160,0) turtle.pendown() turtle.color("red") turtle.circle(50) #第四个圈 turtle.penup() turtle.goto(40,-60) turtle.pendown() turtle.color("yelow") turtle.circle(50) #第五个圈 turtle.penup() turtle.goto(100,-60) turtle.pendown() turtle.color("green") turtle.circle(50) turtle.done
练习的时候总是会漏掉turtle.color 运行出错后又马上修改
最后一行是turtle.done()哦
turtle turtle.showturtle() turtle.write() turtle.forward() turtle.color() turtle.left() turtle.forward() turtle.left() turtle.goto(,) turtle.penup() turtle.goto(,) turtle.pendown() turtle.circle() turtle.done()
显示了以下内容:
C:\Users\Administrator.DESKTOP-JR4QG6M\PycharmProjects\pythonProject\.venv\Scripts\python.exe C:\Users\Administrator.DESKTOP-JR4QG6M\PycharmProjects\pythonProject\pr001.py
Traceback (most recent call last):
File "C:\Users\Administrator.DESKTOP-JR4QG6M\PycharmProjects\pythonProject\pr001.py", line 1, in <module>
import turtle
File "C:\Users\Administrator.DESKTOP-JR4QG6M\PycharmProjects\pythonProject\turtle.py", line 2, in <module>
turtle.showturtle() #显示箭头
^^^^^^^^^^^^^^^^^
AttributeError: partially initialized module 'turtle' has no attribute 'showturtle' (most likely due to a circular import)
Process finished with exit code 1
代码错误认真核对代码
老师,你的奥运五环有问题,五个圆不是连在一起的
这个图标本来就是套在一起的,你想只是相连的话可以自己改一下位置
turtle.circle(50)
这里的50指的是半径还是直径
半径
老师,我想问就是为什么第二行和第三行交换之后运行不会执行蓝色的操作
这里应该不影响的吧
写turtle.color("red")时,光标会停留在引号之前,例如turtle.color("red光标位置")。在写下一行代码时,还要敲击向右箭头,才能回车。
这种情况是否有快捷键。不用敲击向右键,直接就可以回车编辑下一行
没有的