hohahahahah 2017-06-25 08:05 采纳率: 55.6%
浏览 1218
已采纳

python问题 求大神解答

我是个小白/ 这里有个问题不太懂 求解

代码送上

 #encoding:utf-8
#!/user/bin/python

import urllib.request
import city
import time
import json
import tkinter as tk
import win32api

class Application(tk.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.pack()
        self.create_widgets()


    def create_widgets(self):
        self.lable1=tk.Label()
        self.lable1.pack(side="top")
        self.lable1["text"]="请输入一个城市 \n 例如:东莞/北京/上海……"

        self.CityInputTEXT=tk.Text()
        self.CityInputTEXT.pack(side='bottom')


        self.button1=tk.Button()
        self.button1.pack(side="bottom")
        self.button1['text']="查询"
        if self.button1['command'] :
            return self.CityInputTEXT["text"]




    def chaxun(CTname):
        cityname=city.city.get(CTname)

        if cityname:
            url = "http://www.weather.com.cn/data/cityinfo/%s.html" % cityname
            content = urllib.request.urlopen(url).read().decode("utf-8")
            data = json.loads(content)
            result = data['weatherinfo']
            Weather = json.loads(content)
            cityZIDIAN = Weather["weatherinfo"]
            cityInformation = ("%s\n%s\n%s ~ %s") % (cityZIDIAN['city'], cityZIDIAN['weather'],result['temp1'],result['temp2'])
            return cityInformation
        else:
            win32api.MessageBox(0, "There are no this City\n\a没有該城市!", "今天天气")




root = tk.Tk()

app=Application(root)






app.mainloop()

图片说明
运行后是这样的

我想要 使用查询功能

在app.mainloop()上面加了一句

 win32api.MessageBox(0,app.chaxun(app.create_widgets()),"")

结果就运行错误 如图
图片说明

希望大神能快点解答
小弟在此谢过

  • 写回答

5条回答 默认 最新

  • 战在春秋 2017-06-25 08:14
    关注
     def chaxun(CTname):   //函数参数数目为1,调用时,传了2个参数,不匹配。
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?