【发布时间】:2021-05-02 09:48:01
【问题描述】:
我想在 IBM watson 中显示一些 Python 字典的上下文作为输出。 例如,如果我有这样的字典
{'author': 'Bloomberg News',
'title': 'India Crisis Worsens; N.Y. Deaths at 5-Month Low: Virus Update',
'description': 'India Crisis Worsens; N.Y. Deaths at 5-Month Low: Virus Update',
'url': 'https://www.bloombergquint.com/business/n-y-deaths-at-5-month-low-india-crisis-deepens-virus-update',
'source': 'Bloomberg | Latest And Live Business',
'image': None,
'category': 'business',
'language': 'en',
'country': 'us',
'published_at': '2021-05-02T04:48:26+00:00'}
然后在 IBM Watson Assistant 中打印标题作为输出,我们需要这样写:
<?data['title']?>
这将给出输出:India Crisis Worsens;纽约州死亡人数处于 5 个月低点:病毒更新
如果我有这样的字典:
[{'author': 'BQ Desk',
'title': 'Coronavirus Updates: India Reports 3.9 Lakh New Covid Cases, 3,689 Deaths',
'description': 'Coronavirus Updates: India Reports 3.9 Lakh New Covid Cases, 3,689 Deaths',
'url': 'https://www.bloombergquint.com/coronavirus-outbreak/coronavirus-updates-india-reports-39-lakh-new-covid-cases-3689-deaths',
'source': 'Bloomberg | Latest And Live Business',
'image': None,
'category': 'business',
'language': 'en',
'country': 'us',
'published_at': '2021-05-02T05:15:34+00:00'},
{'author': None,
'title': 'Leasebak is geen heilige koe meer',
'description': 'Managers met een leasebak in je arbeidsvoorwaarden, de vanzelfsprekendheid van de auto van de zaak gaat er vanaf. Als je nu solliciteert, zijn er steeds minder bedrijven die daar zomaar in willen meegaan. Door corona en thuiswerken nemen bedrijven hun mobiliteit nog eens extra onder de loep, zien leaseorganisaties en werkgeversorganisatie AWVN.',
'url': 'https://www.telegraaf.nl/financieel/1632068442/leasebak-is-geen-heilige-koe-meer',
'source': 'De Telegraaf - Financieel Overzicht',
'image': 'https://www.telegraaf.nl/images/1200x630/filters:format(jpeg):quality(80)/cdn-kiosk-api.telegraaf.nl/a64d720a-a9c6-11eb-83a5-02d1dbdc35d1.jpg',
'category': 'business',
'language': 'nl',
'country': 'nl',
'published_at': '2021-05-02T05:00:00+00:00'},
{'author': 'Bloomberg News',
'title': 'India Crisis Worsens; N.Y. Deaths at 5-Month Low: Virus Update',
'description': 'India Crisis Worsens; N.Y. Deaths at 5-Month Low: Virus Update',
'url': 'https://www.bloombergquint.com/business/n-y-deaths-at-5-month-low-india-crisis-deepens-virus-update',
'source': 'Bloomberg | Latest And Live Business',
'image': None,
'category': 'business',
'language': 'en',
'country': 'us',
'published_at': '2021-05-02T04:48:26+00:00'},
{'author': 'FE Online',
'title': 'Coronavirus in India Live News: PM Modi to meet experts today to review oxygen & medicine availability; India reports 3.92 lakh Covid-19 cases',
'description': 'Coronavirus Daily Cases and Deaths in India, Covid-19 India Lockdown, May 1 Phase 3 vaccine drive, Day 2 vaccination drive for 18+ years, CoWIN Covid-19 Vaccination Registration, May 2: Prime Minister Narendra Modi is expected to review the human resource situation, in relation to the Covid-19 pandemic, and ways to augment it.',
'url': 'https://www.financialexpress.com/lifestyle/health/coronavirus-lockdown-in-india-coronavirus-cases-in-india-today-live-covid-19-cowin-vaccine-registration-vaccination-drive-rollout-coronavirus-daily-cases-and-deaths-in-india-covid-19-lockdown-in-del-2/2244047/',
'source': 'The Financial Express',
'image': 'https://images.financialexpress.com/2021/05/covid-second-wave.jpg',
'category': 'business',
'language': 'en',
'country': 'us',
'published_at': '2021-05-02T04:28:25+00:00'},
{'author': 'Uppsala University',
'title': 'Newly Discovered Immune Cell Function Vital to Healing May Lead to Treatments for Cancer and Cardiovascular Diseases',
'description': 'Cardiovascular disease, the most common cause of death, is the result of oxygen deprivation as blood perfusion to affected tissue is prevented. To halt the...The post Newly Discovered Immune Cell Function Vital to Healing May Lead to Treatments for Cancer and Cardiovascular Diseases appeared first on SciTechDaily.',
'url': 'https://scitechdaily.com/newly-discovered-immune-cell-function-vital-to-healing-may-lead-to-treatments-for-cancer-and-cardiovascular-diseases/',
'source': 'Scitechdaily | Science Space And Technology News 2017',
'image': None,
'category': 'science',
'language': 'en',
'country': 'us',
'published_at': '2021-05-01T22:40:45+00:00'}]
那么如何在XML中打印每篇文章的标题名称(如我上面提到的语法)。
Desired Output:
Coronavirus Updates: India Reports 3.9 Lakh New Covid Cases, 3,689 Deaths
Leasebak is geen heilige koe meer
India Crisis Worsens; N.Y. Deaths at 5-Month Low: Virus Update
Coronavirus in India Live News: PM Modi to meet experts today to review oxygen & medicine availability; India reports 3.92 lakh Covid-19 cases
Newly Discovered Immune Cell Function Vital to Healing May Lead to Treatments for Cancer and Cardiovascular Diseases
【问题讨论】:
-
我删除了 Python 标签。我假设这是在 Watson Assistant 中,而不是使用 Python SDK 或 Python 客户端,对吗?
标签: xml ibm-cloud ibm-watson watson-assistant