代码拉取完成,页面将自动刷新
import urllib.request
import json
import turtle
import time
url = 'http://www.luohanye.com/astros.json'
response = urllib.request.urlopen(url)
result = response.read().decode('utf-8')
astros = json.loads(result)
print('People in Space:', astros['number'])
people = astros['people']
for p in people:
print(p['name'])
print('------------------------')
# Where is the ISS?
url = 'http://www.luohanye.com/iss-now.json'
response = urllib.request.urlopen(url)
result = response.read().decode('utf-8')
issNow = json.loads(result)
location = issNow['iss_position']
lat = float(location['latitude'])
lon = float(location['longitude'])
print('Latitude', repr(lat))
print('Longitude', repr(lon))
screen = turtle.Screen()
screen.setup(720, 360)
screen.setworldcoordinates(-180, -90, 180, 90)
screen.bgpic('img/map.gif')
screen.register_shape('img/iss.gif')
iss = turtle.Turtle()
iss.shape('img/iss.gif')
iss.setheading(90)
# 提起画笔
iss.penup()
# 移动位置
iss.goto(lon, lat)
# Space Center, Houston
lat = 29.5502
lon = -95.097
location = turtle.Turtle()
location.penup()
location.color('yellow')
location.goto(lon, lat)
location.dot(5)
location.hideturtle()
# 计算
url = 'http://api.open-notify.org/iss-pass.json?lat=' + str(lat) + '&lon=' + str(lon)
response = urllib.request.urlopen(url)
result = json.loads(response.read().decode('utf-8'))
# print result
over = result['response'][1]['risetime']
time1 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(over))
print(time1)
# location.write(time.ctime(over))
location.write(time1)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。