python错误"不能分配给函数调用"

时间:2017-03-17 12:59:15

标签: python syntax

这是我的代码:

#-*- coding:utf-8 -*-
import Tkinter as tk

class App:
    def __init__(self,root):
        frame=tk.Frame(root)
        frame.pack()
        self.hi_there = tk.Button(frame,text='打招呼',fg = command = self.say_hi)
        self.hi_there.pack()

    def say_hi(self):
        print('互联网的广大朋友们大家好,我是小甲鱼')

root=tk.Tk()
app=App(root)
root.mainloop()

1 个答案:

答案 0 :(得分:2)

fg = command = self.say_hi语法无效;更改为command = self.say_hi然后运行