如果我在Python提示符下执行print(dir(pychromecast))
,我将得到此消息底部的列表。哪些方法应该有效?因为有些会抛出一个属性错误,比如pychromecast.get_device_status()
,而有些则像_get_chromecast_from_host
或get_chromecasts
抛出一个属性错误,比如:
AttributeError: module 'pychromecast' has no attribute 'get_chromehosts'
是不是我在做/理解一些根本错误的事情?名字前面的_
是否也起作用?你知道吗
如前所述,这里是dir的输出:
['APP_BACKDROP', 'APP_DASHCAST', 'APP_MEDIA_RECEIVER', 'APP_PLEX',
'APP_SPOTIFY', 'APP_YOUTUBE', 'CAST_TYPES', 'CAST_TYPE_CHROMECAST',
'Chromecast', 'ChromecastConnectionError', 'ControllerNotRegistered',
'DeviceStatus', 'IDLE_APP_ID', 'IGNORE_CEC', 'LaunchError',
'MultipleChromecastsFoundError', 'NoChromecastFoundError', 'NotConnected',
'PyChromecastError', 'PyChromecastStopped', 'STREAM_TYPE_BUFFERED',
'UnsupportedNamespace', '_LOGGER', '__all__', '__builtins__', '__cached__',
'__doc__', '__file__', '__loader__', '__name__', '__package__',
'__path__', '__spec__', '__version__', '__version_info__',
'_get_chromecast_from_host', '_get_chromecast_from_service',
'cast_channel_pb2', 'config', 'controllers', 'dial',
'discover_chromecasts', 'discovery', 'error', 'fnmatch', 'get_app_config',
'get_chromecasts', 'get_device_status', 'get_possible_app_ids', 'json',
'logging', 'reboot', 'requests', 'socket_client', 'start_discovery',
'stop_discovery', 'threading']
他们都应该“工作”。其中有些是方法,有些是变量。你试过
_get_chromecast_from_host
和_get_chromecast_from_host()
吗?至于属性前面的uu或uuu,这意味着它受到保护,您可能不应该直接修改它,尽管只读取它就可以了。至少这是我的理解:)问题的一部分似乎是打字错误。您提到
get_chromecasts
,但您的例外行提到chrome主机:有没有可能您在调用
_get_chromecast_from_host
时也有输入错误,或者提供了错误的参数?你能提供那个函数调用的具体例外情况吗?你知道吗相关问题 更多 >
编程相关推荐