Python - turtle circular import

 
Vista:

turtle circular import

Publicado por lino godoy (1 intervención) el 07/04/2021 14:09:40
Quiero aprender a programar y esta viendo tutoriales que nada para entender comandos y todo pero a pesar de hacerlo igual me saltan esos errores alguien sabe que puede ser
Traceback (most recent call last):
File "c:/Users/marjorie/Desktop/prgramacion/programar/python one/copy.py", line 1, in <module>
import turtle
File "C:\Users\marjorie\AppData\Local\Programs\Python\Python38\lib\turtle.py", line 115, in <module>
from copy import deepcopy
File "c:\Users\marjorie\Desktop\prgramacion\programar\python one\copy.py", line 8, in <module>
wn = turtle.Screen()
AttributeError: partially initialized module 'turtle' has no attribute 'Screen' (most likely due to a circular import)
PS C:\Users\marjorie\Desktop\prgramacion\programar\python one>


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import turtle
import time
import random
 
 
pospones = 0.1
#ventana
wn = turtle.Screen()
wn.title("Snake Game")
wn.bgcolor('blue')
wn.setup(600, 600)
wn.tracer()
 
#cabeza:
cabeza = turtle.Turtle()
cabeza.speed(10)
cabeza.shape("square")
cabeza.color('white')
cabeza.penup()
cabeza.goto(0, 0)
cabeza.direction = "none"
 
#comida:
comida=turtle.Turtle()
comida.speed(0)
comida.shape("circle")
comida.color('red')
comida.penup()
comida.goto(0, 100)
comida.direction = "none"
 
#cuerpo serpiente
segmentos = []
 
 
#funciones
 
#cambiar movimientos
def arriba():
  cabeza.direction = "up"
def abajo():
      cabeza.direction = "down"
def derecha():
      cabeza.direction = "left"
def izquiera():
      cabeza.direction = "right"
 
#teclado
wn.listen()
wn.onkeypress(arriba,"Up")
wn.onkeypress(abajo,"Down")
wn.onkeypress(derecha,"Left")
wn.onkeypress(izquiera,"Right")
#movimiento
def mov():
 
 
 if cabeza.direction == "up":
     y = cabeza.ycor()
     cabeza.sety(y + 20)
 if cabeza.direction == "down":
     y = cabeza.ycor()
     cabeza.sety(y - 20)
 
 if cabeza.direction == "right":
     x = cabeza.xcor()
     cabeza.setx(x + 20)
 
 if cabeza.direction == "left":
     x = cabeza.xcor()
     cabeza.setx(x - 20)
 
 
 
while True:
 wn.update()
 
 if cabeza.distance(comida)< 20:
        x = random.randint(-280, 280)
        y = random.randint(-280, 280)
 
        nuevo_segmento.goto(0,0)
        nuevo_segmento = turtle.Turtle()
        nuevo_segmento.speed(0)
        nuevo_segmento.shape("square")
        nuevo_segmento.color("grey")
        nuevo_segmento.penup()
        segmentos.append(nuevo_segmento)
 
 
 totalseg = len(segmentos)
 for index in range(totalseg -1, 0, -1):
     x = segmentos[index - 1].xcor()
     Y = segmentos[index - 1].ycor()
     segmentos[index].goto(x,y)
 
 mov()
 time.sleep(pospones)
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder