📜  Python|功能 |问题 7

📅  最后修改于: 2022-05-13 01:58:11.578000             🧑  作者: Mango

Python|功能 |问题 7

以下程序的输出是什么:

import re
sentence = 'horses are fast'
regex = re.compile('(?P\w+) (?P\w+) (?P\w+)')
matched = re.search(regex, sentence)
print(matched.groupdict())

(A) {'animal': 'horses', 'verb': 'are', 'adjective': 'fast'}
(B) ('马', '是', '快')
(C) '马跑得快'
(D) ‘是’答案:(一)
说明:此函数返回一个包含所有匹配项的字典。
这个问题的测验