python으로 프로그램을 작성하고 지하 예보에서 아이콘을 넣으려고 시도했지만 라인에 labelimg1 어떤 아이콘도 표시하지 말아주십시오. 오류가 _ 생하지 않습니다. 아무도 도와 줄 수 있어요.weather underground forecast icon 작성 방법
코드의 일부를 여기에 넣었습니다. 미리 감사드립니다.
URL = "http://api.wunderground.com/api/xxxxxxxxx/forecast/q/PT/Lisbon.json"
temp = urllib.request.urlopen(url)
json_string = temp.read().decode('utf-8')
parsed_json = json.loads(json_string)
high = parsed_json['forecast']['simpleforecast']['forecastday'][0]['high']['celsius']
low = parsed_json['forecast']['simpleforecast']['forecastday'][0]['low']['celsius']
con = parsed_json['forecast']['simpleforecast']['forecastday'][0]['conditions']
day = parsed_json['forecast']['simpleforecast']['forecastday'][0]['date']['day']
high1 = parsed_json['forecast']['simpleforecast']['forecastday'][1]['high']['celsius']
low1 = parsed_json['forecast']['simpleforecast']['forecastday'][1]['low']['celsius']
con1 = parsed_json['forecast']['simpleforecast']['forecastday'][1]['conditions']
day1 = parsed_json['forecast']['simpleforecast']['forecastday'][1]['date']['day']
**icon = parsed_json['forecast']['simpleforecast']['forecastday'][0]['icon']**
**img7 = PhotoImage(icon)**
img8 = PhotoImage(file='c:/House/PNG/clear.png')
**labelimg1 = Label(self, image=img7)**
labelimg2 = Label(self, image=img8)
label1 = Label(self, text="Dia: %s , Céu: %s" % (day, con,), font="Arial 12 bold")
label2 = Label(self, text="Temperatura miníma de: %sº - Temperatura máxima de: %sº " % (low, high,),
font="Arial 12 bold")
label3 = Label(self, text="Dia: %s , Céu: %s " % (day1, con1,), font="Arial 12 bold")
label4 = Label(self, text="Temperatura miníma de: %sº - Temperatura máxima de: %sº " % (low1, high1,),
font="Arial 12 bold")
label1.pack(pady=15)
**labelimg1.image = img7
labelimg1.pack()**
label2.pack()
label3.pack(pady=20)
labelimg2.image = img8
labelimg2.pack()
label4.pack()
temp.close()
아니 최소한의 예. 또한 코드를 수동으로 작성해보십시오. json 출력을 잡고, 아이콘을 추출하고, 파이썬 코드를 작성하여 표시하십시오. Python을 처음 접하는 것은 아닙니다. 다루기 쉬운 덩어리로 문제를 해결하는 것은 초보적인 기술입니다. – MSalters
죄송합니다, 이해가 안되요, 어떻게 아이콘을 추출합니까?, 나는 모든 코드를 씁니다. 고맙습니다. – Marques
그게 제가 지적하고자하는 바입니다. 문제를 해결할 때까지 작고 작은 비트로 문제를 해결하십시오. – MSalters