be_here_now 2020-03-15 22:54 采纳率: 100%
浏览 1995
已采纳

Python,turtle库中填充颜色为什么没有在规定的区域内?

图片说明
初学者,数据都是自己拼凑的,这是我的代码,真的不会了
from turtle import*
color("red","yellow")#
speed(50)
begin_fill()
while True:
forward(200)
left(170)
if abs(pos())<1:
break
end_fill()
penup()
goto(90,-45)
pensize(3)
pencolor("green")
pendown()
seth(270)
fd(26)
circle(-100,40)
circle(200,45)
color("green","green")
begin_fill()
penup()
goto(45,-170)
pendown()
seth(320)
circle(77,99)
penup()
goto(45,-170)
pendown()
seth(59)
circle(-77,99)
penup()
goto(45,-170)
pendown()
seth(221)
circle(-77,99)
penup()
goto(45,-170)
pendown()
seth(120)
circle(77,99)
end_fill()

  • 写回答

1条回答 默认 最新

  • weixin_46543738 2020-03-16 11:30
    关注

    我也是新手turtle学的时候只学了比较基本的,这是我修改后的代码,总而言之就是你的最后一个begin_fill放早了,空白处是原本你写的begin_fill,我把他往下挪了点位置就ok了,你自己理解下。
    import turtle as t
    t.color("red","yellow")
    t.speed(40)
    t.begin_fill()
    while True:
    t.forward(200)
    t.left(170)
    if abs(t.pos())<1:
    break
    t.end_fill()
    t.penup()
    t.goto(90,-45)
    t.pensize(3)
    t.pencolor("green")
    t.pendown()
    t.seth(270)
    t.fd(26)
    t.circle(-100,40)
    t.circle(200,45)
    t.color("green","green")

    t.penup()
    t.goto(45,-170)
    t.pendown()
    t.begin_fill()
    t.seth(320)
    t.circle(77,99)
    t.penup()
    t.goto(45,-170)
    t.pendown()
    t.seth(59)
    t.circle(-77,99)
    t.penup()
    t.goto(45,-170)
    t.pendown()
    t.seth(221)
    t.circle(-77,99)
    t.penup()
    t.goto(45,-170)
    t.pendown()
    t.seth(120)
    t.circle(77,99)
    t.end_fill()

    t.done()

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测