Convert SRE_Match object to string

后端 未结 2 928
执念已碎
执念已碎 2020-12-29 04:34

The output of my re.search returns <_sre.SRE_Match object at 0x10d6ed4e0> I was wondering how could I convert this to a string? or a more rea

相关标签:
2条回答
  • 2020-12-29 04:53

    You should do it as:

    result = re.search(your_stuff_here)
    if result:
        print result.group(0)
    
    0 讨论(0)
  • 2020-12-29 05:10

    If you want to see all groups in order:

    result = re.search(your_stuff_here)
    if result:
        print result.groups()
    
    0 讨论(0)
提交回复
热议问题