首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >大佬们,为什么我的程序在input的时候turtle界面会无响应?

大佬们,为什么我的程序在input的时候turtle界面会无响应?

提问于 2020-07-05 19:37:44
回答 0关注 0查看 241
代码语言:javascript
复制
import turtle
import random
import time
t = turtle.Turtle()

t.ht()

def pixel(x,y,c,forward=100):
    t.color(c)
    t.penup()
    t.goto(x, y)
    t.pendown()
    t.begin_fill()
    for i in range(4):
        t.forward(forward)
        t.left(90)
    t.end_fill()

turtle.tracer(False)
pixel(-50,-50,"pink")
pixel(-150,-50,"green")
pixel(50,-50,"blue")
pixel(-50,50,"yellow")
pixel(-50,-150,"red")
pixel(-150,50,"purple")
pixel(-150,-150,"grey")
pixel(50,50,"orange")
pixel(50,-150,"brown")
turtle.tracer(True)

t1=turtle.Turtle()
t1.shape("turtle")

def tur(a):
    t1.penup()
    t.ht()
    if a == 1:
        t1.goto(-100,100)
    elif a==2:
        t1.goto(0,100)
    elif a==3:
        t1.goto(100,100)
    elif a==4:
        t1.goto(-100,0)
    elif a == 5:
        t1.goto(0,0)
    elif a==6:
        t1.goto(100,0)
    elif a==7:
        t1.goto(-100,-100)
    elif a==8:
        t1.goto(0,-100)
    elif a==9:
        t1.goto(100,-100)
    else:
        print("你是怎么做到的?")
        exit(0)
    t1.pendown()
    t1.showturtle()
    time.sleep(1)
    t1.ht()

t2 = turtle.Turtle()
t2.speed(0)
t2.color("violet")
t2.ht()

while True:
    s=""
    for x in range(4):
        area = random.randint(1,9)
        #print(area)
        tur(area)
        s += str(area)

    a=input("请输入海龟的出现顺序:")

    if a == s:
        t2.penup()
        t2.goto(-30,-200)
        t2.pendown()
        t2.write("回答正确!",font=("行楷",20))
        break

    else:
        t2.penup()
        t2.goto(-100,-200)
        t2.pendown()
        t2.write("回答错误 请再试一次",font=("行楷",20))
        time.sleep(3)
        t2.clear()

turtle.done()

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档