这是我目前的代码。我找不到这个问题重新匹配你知道吗
import os
import re
folderpath = 'D:/Workspace'
typeOfFile = [".c", ".C", ".cpp", ".CPP"]
for dirname, dirnames, filenames in os.walk(folderpath):
for filename in filenames:
if filename.endswith(tuple(typeOfFile)):
data= open(os.path.join(dirname, filename), "r").readlines()
m= re.match(r'author*.[^:=]*[:=]*(.[^\n]+)', data, re.DOTALL)
if m:
author = m.group(1)
else:
author = 'unknown'
print "author is this case is:", author, "in file", filename
我想在文本文件中搜索字符串作者。你知道吗
阅读the docs:
改用^{} 。你知道吗
相关问题 更多 >
编程相关推荐