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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器