python sample docs
. 我正在使用create\u iot\u topic函数。
我的代码如下:
def create_iot_topic(topic_url):
# eg: topic_url = 'projects/<projectname>/topics/<topicname>'
topic1 = pubsub_client.topic(topic_url)
print(topic_url)
policy = topic1.get_iam_policy()
publishers = policy.get('roles/pubsub.publisher', [])
publishers.add(policy.service_account(
'cloud-iot@system.gserviceaccount.com'))
policy['roles/pubsub.publisher'] = publishers
topic1.set_iam_policy(policy)
return topic1
调用此函数时,第5行出现错误(get\u iam\u policy()函数):
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 1438: ordinal not in range(128)
我需要帮助解决这个问题。有人能告诉我哪里出了问题吗。
非常感谢。