Ai
1 Star 1 Fork 1

luohanye/python-core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
iss.py 1.51 KB
一键复制 编辑 原始数据 按行查看 历史
luohanye 提交于 2019-08-23 22:16 +08:00 . first commit
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)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/indexman/python-core.git
git@gitee.com:indexman/python-core.git
indexman
python-core
python-core
master

搜索帮助