2017-03-17 69 views
-6

这是我的代码:蟒蛇错误“无法分配到函数调用”

#-*- 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

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

+0

非常感谢您 – user7727210