Como hacer un bucle a un código terminado
Publicado por Guillermo (1 intervención) el 24/04/2021 16:25:12
Apenas esta tratando de hacer un código por mi mismo, lo termine con ayuda de tutoriales, pero ahora no se como ponerlo en buble, o mas bien, que se actualice cada segundo.
Lo anterior es el código, adjunto el archivo original.
Si me pueden ayudar, les estaría muy agradecido
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
#!/bin/python3
import json
import turtle
import urllib.request
import time
url = 'http://api.open-notify.org/astros.json'
respuesta = urllib.request.urlopen(url)
resultado = json.loads(respuesta.read())
print('Personas en el espacio: ', resultado['number'])
personas = resultado['people']
for p in personas:
print(p['name'])
url = 'http://api.open-notify.org/iss-now.json'
respuesta = urllib.request.urlopen(url)
resultado = json.loads(respuesta.read())
lugar = resultado['iss_position']
lat = float(lugar['latitude'])
lon = float(lugar['longitude'])
print('Latitud: ', lat)
print('Longitud', lon)
pantalla = turtle.Screen()
pantalla.setup(1280, 640)
pantalla.setworldcoordinates(-180, -90, 180, 90)
pantalla.bgpic('mapa.gif')
pantalla.register_shape('iss2.gif')
iss = turtle.Turtle()
iss.shape('iss2.gif')
iss.setheading(90)
iss.penup()
iss.goto(lon, lat)
# San Miguel Toplejo
lat = 19.19260787816427
lon = -99.14360857267664
lugar = turtle.Turtle()
lugar.penup()
lugar.color('white')
lugar.goto(lon, lat)
lugar.dot(5)
lugar.hideturtle()
url = 'http://api.open-notify.org/iss-pass.json'
url = url + '?lat=' + str(lat) + '&lon=' + str(lon)
respuesta = urllib.request.urlopen(url)
resultado = json.loads(respuesta.read())
encima = resultado['response'][1]['risetime']
estilo = ('Arial', 14, 'bold')
lugar.write(time.ctime(encima), font=estilo, align = 'center')
Lo anterior es el código, adjunto el archivo original.
Si me pueden ayudar, les estaría muy agradecido
- iss.7z(91,5 KB)
Valora esta pregunta


0