题目内容

采用re模块中的( )方法,可以将字符串数据类型的正则表达式编译为正则表达式对象。

A. re.split
B. re.sub
C. re.compile
D. re.finditer

查看答案
更多问题

匹配对象提供( )方法用于返回一个元组,包含所有匹配的子组。

A. match.group
B. match.groupdict
C. match.groups
D. match.tuple

re.split('(\W+)', 'abc, abc,defg')结果是( )。

A. ['abc', ',', 'abc', ',', 'defg']
B. ('abc', ',', 'abc', ',', 'defg')
C. ['abc', 'abc', 'defg']
D. ('abc', 'abc', 'defg')

以下程序的执行结果是( )。text = "failure is the price of success, 666."print(re.sub('\s+','-',text))

A. failure-is-the-price-of-success,666.
B. failure-is-the-price-of-success,-666.
C. failure is the price of success,-666.
D. failure is the price of success, 666.

以下程序的执行结果是( )。import retext = "failure is the price of success, 666"match1 = re.match(r"(\w+) (\w+)", text)match1.span(), match1. span(1), match1.span(2)

A. (1, 11), (1, 8), (9, 11)
B. (0, 10), (0, 7), (8, 10)
C. ((1, 11), (1, 8), (9, 11))
D. ((0, 10), (0, 7), (8, 10))

答案查题题库