簡體   English   中英

python dbus如何獲取對象值

[英]python dbus how to get object value

import dbus

session_bus = dbus.SessionBus()
print(session_bus)

serviceName = "com.qcom.QCAT"
service = session_bus.get_object(
    serviceName, # Bus name
    "/Applications/QCAT/QCAT/bin/QCAT", # Object path
)

print(service)
appVersion = service.get_dbus_method('AppVersion')
print(appVersion)

我想在此代碼中打印appVersion,但實際上它打印對象_DeferreMethod對象如何獲取AppVersion的值。(arguemnts) 圖片

您將在appVersion中獲取有關該方法的appVersion ,而不是調用它並獲取其返回值。 嘗試添加如下內容:

service_application = dbus.Interface(service, 'com.qcom.Application')
appVersion = service_application.AppVersion()
print(appVersion)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM