Python 无法在twitter API中调用status.place.country和status.place.name

Python 无法在twitter API中调用status.place.country和status.place.name,python,twitter,Python,Twitter,我在使用tweepy通过流式api获取推文时发现了一个奇怪的问题 也就是说,当我想要格式化json输出时,函数如下: def info_select(status, all_info={}): """ select the info we need and wrap it by json format Return: a json obj all_info """ # set the tweet id all_info["tweet_id_str"

我在使用tweepy通过流式api获取推文时发现了一个奇怪的问题

也就是说,当我想要格式化json输出时,函数如下:

def info_select(status, all_info={}):
    """
    select the info we need and wrap it by json format
    Return: a json obj all_info
    """
    # set the tweet id
    all_info["tweet_id_str"] = status.id_str
    # set the content of tweet
    all_info["tweet_text"] = status.text
    # set the time for tweet
    all_info["created_at"] = str(status.created_at)
    # set user id and screen_name
    all_info["user_id"] = status.user.id_str
    all_info["screen_name"] = status.user.screen_name
    # set the country & city
    all_info["country"] = status.place.country
    all_info["city_name"] = status.place.name
    # set the favorite_count
    all_info["favorite_count"] = str(status.favorite_count)
    # set the retweet_count
    all_info["retweet_count"] = str(status.retweet_count)

    json_obj = json.dumps(all_info)
    return json_obj
当我调用“status.user.id\u str”时,它会工作并获取用户id,调用“status.user.screen\u name”时也是如此

但是,代码“status.place.country”或“status.place.name”将导致“NoneObject”异常

但是国家和名字是地方obj的两个属性!!! 参考:

你能帮我调用这两个参数吗?
真的吗~

你能打印收到的
状态的值吗?@Satish Garg“'NoneType'对象没有属性'country'”或“name”