我需要一些代码方面的帮助。当我有输入import test
时,在player.py中获取self.channel
的列表有问题,但是我得到了一个错误:attribute error:type object'MyClass'在尝试运行脚本时没有属性'channel'。
此行上的错误突出显示:
self.channel = test.MyClass.channel()
在test.py中显示:
from player import MyPlayer
class MyClass(xbmcgui.WindowXML):
def __init__(self, *args, **kwargs):
self.channel = list()
在player.py中:
import test
class MyPlayer(xbmcgui.WindowXML):
def __init__(self, *args, **kwargs):
self.channel = test.MyClass.channel()
我想从test.py中获取self.channel
,以获取字符串列表。你能告诉我如何让self.channel
从test.py脚本获取列表吗?
从
channel()
中删除括号。它是一个字段,而不是函数。在MyClass
中添加括号,以便调用构造函数。所有代码组合在一起:
测试.py
玩家.py
相关问题 更多 >
编程相关推荐