Ok,我是Alexa技能开发的新手,但它进行得很好,我的技能来得很好,然而,我想添加一些更多的内容在卡片的形式。要用来填充卡的数据id是列表形式的。所以我想我会试着直接传递列表(我不认为它会工作,但值得一试)。文档中没有解释将列表传递到卡系统的内容。有人能解释一下如何做到这一点吗?
intent函数如下所示:
@ask.intent('TopTenCounties')
def top_ten():
top_countries = get_top_ten_countries()
stats = []
for item in top_countries[1]:
stat = str(item[0]) + ' ' + str(item[1])
stats.append(stat)
msg = "The top ten countries are, {}".format(top_countries[0])
return statement(msg).standard_card(title='Top Ten Usage Stats:',
text=stats,
large_image_url='url.com/img.png')发布于 2017-03-13 22:32:12
Alexa的卡片只接受文本,目前不支持其他丰富的格式(https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/providing-home-cards-for-the-amazon-alexa-app)。这里发生的情况是列表被自动转换为字符串。你可能想自己做一个小函数,这样你就可以更好地控制它是如何完成的。
def lst2str(lst, last='and'):
if len(lst)==1:
return lst[0]
else:
return ', '.join(lst[0:-1]) + ' ' + last + ' ' + lst[-1]https://stackoverflow.com/questions/41789966
复制相似问题