[問題]請問,有大大能幫我看一嗎?(已稍作修改)

看板Python作者 (aeron)時間11年前 (2014/05/15 15:41), 11年前編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/1
我做了一些更改順便加上apua大的“把連結看起來比較簡單” 這是我目前寫的, 不知道哪裡出問題~按了按鈕可是跑不出來資訊 想要變成一個可以按了就能看到的即時氣象資訊 像是這個圖一樣 http://ppt.cc/Q~m1 有大大能幫忙一下嗎??? 謝謝!!! from urllib import urlopen from Tkinter import * from re import findall the_window = Tk() the_window.title('The Weather Report') the_window.geometry('600x500+10+10') radiobutton = ['Brisbane', 'Sydney', 'Melbourne', 'Adelade', 'Darwin', ' Habart', 'Perth', 'Canberra'] the_label = Label(the_window, text = 'Current Weather', fg ='black', font = ('Arial', 20)).grid(row = 0, column = 0, padx = 2, pady = 2) text_box = Text(the_window, width = 50, height = 20, wrap = WORD, bg = 'light yellow',font =('Arial', 12), borderwidth = 3, relief = 'groove', takefocus = False) the_label = Label(the_window, text = 'Current Weather', fg ='black', font = ('Arial', 20)).grid(row = 0, column = 0, padx = 2, pady = 2) text_box = Text(the_window, width = 50, height = 20, wrap = WORD, bg = 'light yellow',font =('Arial', 12), borderwidth = 3, relief = 'groove',takefocus = False).grid(row = 1, column = 0, padx =10, pady = 10,rowspan = 6, columnspan = 4) Locations = { 'Brisbane': 9388, 'Sydney': 624, 'Melbourne':5594, 'Adelade': 12495, 'Darwin': 11, 'Habart': 15465, 'Perth': 13896, 'Canberra': 3928,} url_template = 'http://rss.weatherzone.com.au/?u=12994-1285&lt=aploc&lc={}&obs=1&fc=1&warn=1' def open_url(i, url): url['locations'] = locations[i] def open_url(event = None): weather_page = urlopen(url_template) html_code = weather_page.read() weather_page.close() text_box.delete(0.0, END) page_date = FINDALL('<lastBuildDate>(.+)</lastBuildDate>', html_code) if len(page_date) != 1: text_box.insert(END,'Erroe: Unable to find unique modification date') else: text_box.insert(END, page_date[0].upper()+'\n\n') title_name = find('<title>(.-)</title>', html_code) for i in range(8): Radiobutton(the_window, text = radiobutton[i], value = i, command = lambda i= i, locations =locations: open_url(i, url)).grid(row= 7, column =i) the_window.mainloop() -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.241.220.100 ※ 文章網址: http://www.ptt.cc/bbs/Python/M.1400139702.A.3B1.html

05/15 21:43, , 1F
有點亂, 先稍微整理了一下: http://goo.gl/Y6qUyJ
05/15 21:43, 1F

05/15 22:18, , 2F
apua大,可以請問你地區後面的數字是???
05/15 22:18, 2F
※ 編輯: aeronan (60.241.220.100), 05/17/2014 17:09:57 ※ 編輯: aeronan (60.241.220.100), 05/17/2014 17:55:04 ※ 編輯: aeronan (60.241.220.100), 05/17/2014 17:56:24 ※ 編輯: aeronan (60.241.220.100), 05/17/2014 19:47:45

05/21 14:35, , 3F
the id of "lc" in those urls
05/21 14:35, 3F
文章代碼(AID): #1JT6-sEn (Python)
文章代碼(AID): #1JT6-sEn (Python)