You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Pushbullet API向频道推送通知报AttributeError错误该如何解决?

错误原因

你调用pb.push_note时传入的channel参数为字符串类型的频道标签,但是pushbullet库要求该参数传入频道实例对象,而非直接传标签字符串。库内部逻辑会尝试读取传入channel参数的channel_tag属性填充请求,字符串不存在该属性,因此触发AttributeError。

修正代码

你需要先从账号绑定的频道列表中匹配到对应标签的频道对象,再传入推送方法:

from pushbullet import PushBullet

API_KEY = myAPIKey
pb = PushBullet(API_KEY)

# 匹配对应标签的频道对象
target_channel = None
for channel in pb.channels:
    if channel.channel_tag == "myTag":
        target_channel = channel
        break

if target_channel:
    push = pb.push_note('Title', 'Desc', channel=target_channel)
else:
    print("未查询到对应标签的频道,请检查标签拼写和频道权限")

内容的提问来源于stack exchange,提问作者geomikeo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.30 15:57:02