【问题标题】:when I read message I am getting extra info. How to avoid that当我阅读消息时,我会得到额外的信息。如何避免这种情况
【发布时间】:2018-05-09 11:35:08
【问题描述】:

我可以阅读来自Pub nub 的消息,但我只想要“是”或“否”。我收到{u'text':'Yes'} 和{u'text':'No'}。如何避免多余的东西?

这是我的代码:

while True:                                             
    result = my_listener.wait_for_message_on(channel)      
    print(result.message) 

【问题讨论】:

    标签: json python-3.x raspberry-pi3 raspbian pubnub


    【解决方案1】:
    while True:                                             
        result = my_listener.wait_for_message_on(channel)      
        print(result.message.get('text')) 
    

    【讨论】:

    • 非常感谢......昨天它试图让一切变得完整,最后你帮助了。它正在工作:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-21
    相关资源
    最近更新 更多