Черепаха дает мне ошибки - Python - PullRequest
0 голосов
/ 25 мая 2020

попробовал несколько новых программ с Turtle. Я знаю, что не так, в WEB IDE он работает, поэтому я предполагаю, что есть проблема с моим IDLE. Я пытался обновить свой пип, черепаху или что-то еще, ничего не помогло. В чем может быть проблема с моей черепахой?

мой код:

import json
import turtle
import urllib.request

url = "http://api.open-notify.org/astros.json"
response = urllib.request.urlopen(url)
result = json.loads(response.read())
#print(result)
print("Leute im Weltall:", result["number"])
people = result["people"]
#print(people)

for p in people:
    print(p["name"]+ " in "+ p["craft"])

newurl = "http://api.open-notify.org/iss-now.json"
newresponse = urllib.request.urlopen(newurl)
newresult = json.loads(newresponse.read())
#print(newresult)
positions = newresult["iss_position"]
lat = positions["latitude"]
long = positions["longitude"]

screen = turtle.Screen()
screen.setup(720,360)
screen.setworldcoordinates(-180, -90, 180, 90)
screen.bgpic('map.jpg')

screen.register_shape("ISS.png")
iss = turtle.Turtle()
iss.shape("ISS.png")
iss.setheading(90)

iss.penup()
iss.goto(long, lat)
turtle.done()

Мой вывод:

> Leute im Weltall: 3 
Chris Cassidy in ISS 
Anatoly Ivanishin in ISS 
Ivan Vagner in ISS 

Traceback (most recent call last):   File
> "C:\Users\Marcell\Desktop\Python\ISS.py", line 27, in <module>
>     screen.bgpic('map.jpg')   File "C:\Program Files\Python38\lib\turtle.py", line 1481, in bgpic
>     self._bgpics[picname] = self._image(picname)   File "C:\Program Files\Python38\lib\turtle.py", line 479, in _image
>     return TK.PhotoImage(file=filename)   File "C:\Program Files\Python38\lib\tkinter\__init__.py", line 4061, in __init__
>     Image.__init__(self, 'photo', name, cnf, master, **kw)   File "C:\Program Files\Python38\lib\tkinter\__init__.py", line 4006, in
> __init__
>     self.tk.call(('image', 'create', imgtype, name,) + options)
> _tkinter.TclError: couldn't recognize data in image file "map.jpg"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...