我re.search
的输出返回<_sre.SRE_Match object at 0x10d6ed4e0>
我想知道如何将其转换为字符串?或者更易读的形式?
答案 0 :(得分:21)
你应该这样做:
result = re.search(your_stuff_here)
if result:
print result.group(0)
答案 1 :(得分:3)
如果您想按顺序查看所有群组:
result = re.search(your_stuff_here)
if result:
print result.groups()
答案 2 :(得分:1)
<_ sre.SRE_Match对象; span =(0,54),match =“''>使用resuilt.group(0),但有一个新问题是AttributeError:'NoneType'对象没有属性'group'