想要读取一个文件并筛选特定的文件名该怎么做呢
資深大佬 : jeblur 6
Very Very New to Python… 我的想法是先 with open 打开文件,然后读每行的内容,并用正则表达式筛选特定的内容。
但查了很多代码好像都没能做成
import re import os import sys stringToMatch = '[^/]*.js' matchedLine = '' with open('access_log.txt') as f: for line in f: if stringToMatch in line: print line
上面是其中一个。。 运行后完全没有输出[一脸懵]
大佬有話說 (3)