1

我正在尝试使用 geograpy 从文本文件中提取英国作为国家名称,但它返回一个空列表。我的代码是:

import geograpy
text = 'I am from the UK'
places = geograpy.get_place_context(text=text)

print (places.countries)

输出:

[]

有没有办法让 ['UK'] 作为输出?谢谢你。

4

1 回答 1

2

尝试:places.other

列出所有不明确是国家、地区或城市的内容。

import geograpy

text = 'I am from the UK'
places = geograpy.get_place_context(text=text)
print(places.other)

输出:

['UK']
于 2020-11-18T22:00:41.060 回答