eag = 'linux'
rpat = re.compile("^\s*%s\s*=\s*('.*\'')" % eag)
试图r'^LIN'
在文本文件中抓取一行,linux = r'^LIN',
lines = [line.strip() for line in open (myfile, 'r')]
for line in lines:
if re.match(rpat, line)
matched = re.match(rpat,line)
got_it = matched.group(1)
# do something here
不太确定我rpat
的是否正确
linux前面有一些空间,然后是一些空间直到=,然后是一些空间r'^LIN',