from tkinter import *
import random
import time
tk = Tk()
tk.title("Pong")
tk.resizable(0,0)
tk.wm_attributes("-topmost", 1)
canvas = Canvas(tk, width=500, height=400, bd=0, highlightthickness=0)
canvas.pack()
tk.update()
class Ball:
def _init_(self, canvas, color):
self.canvas = canvas
self.id = canvas.create_oval()
self.canvas.move(self.id, 245, 100)
def draw(self):
pass
ball = Ball(canvas, 'red')
当我运行代码时,它会返回错误:
TypeError: object() takes no parameters
即使定义了对象的参数。
答案 0 :(得分:3)
正如其他人指出的那样,你需要在pod 'SwiftyXMLParser', :git => 'https://github.com/yahoojapan/SwiftyXMLParser.git', :branch => "swift2.3"
中使用双下划线,
你错过了__init__
电话的论据:
create_oval