Iterate over the lines of a string

前端 未结 6 1823
情深已故
情深已故 2020-11-28 03:15

I have a multi-line string defined like this:

foo = \"\"\"
this is 
a multi-line string.
\"\"\"

This string we used as test-input for a par

6条回答
  •  孤街浪徒
    2020-11-28 04:07

    Regex-based searching is sometimes faster than generator approach:

    RRR = re.compile(r'(.*)\n')
    def f4(arg):
        return (i.group(1) for i in RRR.finditer(arg))
    

提交回复
热议问题