A0嘉诚 2024-02-20 18:44 采纳率: 28.6%
浏览 1

tuetle畫的圓不一樣

import turtle
X=turtle.Pen()
a={}
def putong_eye():
    X.penup()
    X.setpos(-60,0)
    X.pendown()
    X.circle(30)
    X.setheading(90)
    X.penup()
    X.forward(45)
    X.pendown()
    X.setheading(180)
    X.fillcolor("black")
    X.begin_fill()
    X.circle(15)
    X.end_fill()
    #second
    X.setheading(0)
    X.penup()
    X.setpos(60,0)
    X.pendown()
    X.circle(30)
    X.setheading(90)
    X.penup()
    X.forward(45)
    X.pendown()
    X.setheading(180)
    X.fillcolor("black")
    X.begin_fill()
    X.circle(15)
    X.end_fill()
def xieshi_eye():
    X.penup()
    X.setpos(-60,0)
    X.pendown()
    X.circle(30)
    X.setheading(90)
    X.penup()
    X.forward(45)
    X.setheading(180)
    X.forward(10)
    X.pendown()
    X.setheading(180)
    X.fillcolor("black")
    X.begin_fill()
    X.setheading(180)
    X.circle(15)
    X.end_fill()
    #second
    X.setheading(0)
    X.penup()
    X.setpos(60,0)
    X.pendown()
    X.circle(30)
    X.setheading(90)
    X.penup()
    X.forward(45)
    X.setheading(180)
    X.forward(10)
    X.pendown()
    X.setheading(180)
    X.fillcolor("black")
    X.begin_fill()
    X.circle(15)
    X.end_fill()
def putong_mouth():
    X.penup()
    X.setpos(-70,-40)
    X.pendown()
    X.setheading(-30)
    for _count in range(30):
        X.left(2)
        X.forward(5)
def face():
    X.setheading(180)
    X.penup()
    X.setpos(0,120)
    X.pendown()
    for _count in range(60):
        X.left(2)
        X.forward(5)
    for xx in range(35):
        X.left(3.5-(xx/10))
        a[35-xx]=3.5-(xx/10)
        X.forward(3.95)
    X.setheading(0)
    for xx in range(1,36):
        X.left(a[xx])
        X.forward(3.95)
    X.color("BLACK")
    X.penup()
    X.setpos(0,120)
    X.pendown()
    X.setheading(0)
    for _count in range(60):
        X.right(2)
        X.forward(5)
def putong_face():
    X.clear()
    putong_eye()
    face()
    putong_mouth()
putong_face()
print("你好!")
X.clear()
xieshi_eye()
face()
putong_mouth()
name=input("我还没有名字呢,你取一个吧!")

為什麼xieshi_eye兩個眼睛不一樣?

  • 写回答

2条回答 默认 最新

  • GISer Liu 2024-02-20 19:25
    关注

    该回答引用自GPT-3.5,由博主GIS_Liu编写:

    问题出在函数xieshi_eye中,其中对第二只眼睛的位置偏移没有正确设置。具体来说,第二只眼睛的位置应该是在原来的基础上向右平移一定距离,而当前的代码中缺少这一平移操作,导致第二只眼睛的位置不正确。

    解决方案是在xieshi_eye函数中对第二只眼睛的位置进行适当的调整。可以通过在设置位置时增加一个水平方向的偏移量来实现。修改代码如下:

    def xieshi_eye():
        X.penup()
        X.setpos(-60, 0)
        X.pendown()
        X.circle(30)
        X.setheading(90)
        X.penup()
        X.forward(45)
        X.setheading(180)
        X.forward(10)  # 在这里增加水平方向的偏移量
        X.pendown()
        X.setheading(180)
        X.fillcolor("black")
        X.begin_fill()
        X.circle(15)
        X.end_fill()
        
        # second
        X.setheading(0)
        X.penup()
        X.setpos(60, 0)
        X.pendown()
        X.circle(30)
        X.setheading(90)
        X.penup()
        X.forward(45)
        X.setheading(0)  # 重置方向为向右
        X.forward(10)  # 在这里增加水平方向的偏移量
        X.setheading(180)
        X.fillcolor("black")
        X.begin_fill()
        X.circle(15)
        X.end_fill()
    

    通过以上修改,应该能够使得两只眼睛的位置保持一致。

    如果该回答解决了您的问题,请采纳!如果没有,请参考以下方案进行修订

    用户答题指南

    评论

报告相同问题?

问题事件

  • 创建了问题 2月20日