我的课程电影如下:
class Movie(Widget):
def __init__(self, title, image, time, description, trailer, fsk, threeD, **kwargs):
super(Movie, self).__init__(title, image, time, description, trailer, fsk, threeD, **kwargs)
title = StringProperty()
image = StringProperty()
time = StringProperty()
description = StringProperty()
trailer = StringProperty()
fsk = NumericProperty()
threeD = BooleanProperty()
当我运行我的脚本时,Python解释器会告诉我:
TypeError: __init__() missing 7 required positional arguments: 'title', 'image', 'time', 'description', 'trailer', 'fsk', and 'threeD'
那么我做错了什么?我已经有一段时间了。
与此问题相关的整个源代码:
class Movie(Widget):
def __init__(self, title, image, time, description, trailer, fsk, threeD, **kwargs):
super(Movie, self).__init__(title, image, time, description, trailer, fsk, threeD, **kwargs)
title = StringProperty()
image = StringProperty()
time = StringProperty()
description = StringProperty()
trailer = StringProperty()
fsk = NumericProperty()
threeD = BooleanProperty()
class MainView(Widget):
def __init__(self, **kwargs):
super(MainView, self).__init__(**kwargs)
movies = ListProperty()
# movies = self.getMovies()
# for movie in movies:
# self.add_widget(movie)
def getMovies(self, url="http://.../"):
html = lxml.html.parse(url)
titles = html.xpath("//h5")
times = html.xpath("//td[@class='pday ptoday']/span/a")
trailers = html.xpath("//a[@data-modal-trailer-url]/@data-modal-trailer-url")
fsks = html.xpath("//tr[@data-fsk]/@data-fsk")
movies = list()
# for i in range(0, len(titles)):
# movie = Movie(titles[i].text, "images[i]", times[i].text, "", "https:" + trailers[i][:-11], fsks[i], "no")
# movies.append(movie)
return movies
答案 0 :(得分:-1)
我发现kv-lang文件是导致此对象初始化错误的原因。所以我不知道如何修复它,但我认为这是另一个问题,因为这是为什么__init__
被称为