Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python AttributeError:';超级';对象没有属性';testnet';,但是,在super?上调用_dict__时,该属性会出现?_Python_Python 3.x_Attributeerror - Fatal编程技术网

Python AttributeError:';超级';对象没有属性';testnet';,但是,在super?上调用_dict__时,该属性会出现?

Python AttributeError:';超级';对象没有属性';testnet';,但是,在super?上调用_dict__时,该属性会出现?,python,python-3.x,attributeerror,Python,Python 3.x,Attributeerror,我有一个类,它继承binance客户机从其API读取数据。然后我调用BinanceSocketManager,它接收binance客户端的一个实例。但是,当我运行该程序时,出现以下错误: from binance.client import Client from binance.websockets import BinanceSocketManager class Binance_Data(Client): def __init__(self, api_key, api_secre

我有一个类,它继承binance客户机从其API读取数据。然后我调用BinanceSocketManager,它接收binance客户端的一个实例。但是,当我运行该程序时,出现以下错误:

from binance.client import Client
from binance.websockets import BinanceSocketManager

class Binance_Data(Client):
    def __init__(self, api_key, api_secret, requests_params=None, tld='us'):
        super().__init__(api_key, api_secret, requests_params=None, tld='us')

    def data_stream_test(self, data):
        print('------------------')
        print(f"Event Title: {data['e']}")
        print(f"Closing Price: {data['c']}")
        print(convert_unix_to_utc(data['E']))
        print('------------------')

    def data_stream(self):
        ds = BinanceSocketManager(super())
        conn_key = ds.start_symbol_ticker_socket('XLMUSDT', data_stream_test)
        ds.start()
但是,当我在测试方法中打印
super()。\uuuu dict\uuuu
以获取属性时,它将testnet显示为super的属性:

AttributeError: 'super' object has no attribute 'testnet'
调用父方法(如
super().get_ticker()
)没有问题,但是我在这里遇到了一个错误。

super()
不返回类本身,而是返回一个用于调用超类方法的代理,如前所述


不要使用
super()
试试
self

为什么要在那里使用
super()
,而不仅仅是
self
?类的实例也是
客户端的实例。@jasonharper是的,你是对的,谢谢@jasonharper回答,这样我就可以把它标记为已回答并投票给你
{...,'testnet': False, 'timestamp_offset': -8}