gui.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:Weather 作者: dev4love 项目源码 文件源码
def _showWeather(self, city):
        self.info.insert(tk.INSERT, u'?????? #%s, %s# ???...\n\n\n' % (
            city.get(u'city_name_ch'), city.get(u'parent_name_ch')))

        weather_content = self.api.getWeather(city.get(u'id'))
        soup = BeautifulSoup(weather_content, u'html.parser')

        table_tag = soup.find_all(u'table', class_=u'sevendays')[0]
        for child in table_tag.children:
            if not isinstance(child, Tag):
                continue

            date = child.find(u'td', class_=u'date').get_text()
            temp = child.find(u'td', class_=u'temp').get_text()
            desc = child.find(u'td', class_=u'desc').get_text()

            self.info.insert(tk.INSERT, ''.join(date.split()) + '\n')
            self.info.insert(tk.INSERT, ''.join(temp.split()) + '\n')
            self.info.insert(tk.INSERT, ''.join(desc.split()) + '\n')
            self.info.insert(tk.INSERT, u'=================' + '\n')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号