How to use regexp on file, line by line, in Python

后端 未结 7 1885
[愿得一人]
[愿得一人] 2020-12-30 00:24

Here is my regexp: f\\(\\s*([^,]+)\\s*,\\s*([^,]+)\\s*\\)

I\'d have to apply this on a file, line by line. The line by line is OK, simple reading from

相关标签:
7条回答
  • 2020-12-30 01:20

    Another way to do

    import re
    [line for line in open('file.txt') if re.match(r'f\(\s*([^,]+)\s*,\s*([^,]+)\s*\)',line)]
    
    0 讨论(0)
提交回复
热议问题