1.正則表達式中最常見的符號和字符
2.正則常用的函數和方法
3.其他
line.startswith('python')
line[:-1].endswith('a')
例:def find_file(fname):
f=open(fname)
for line in f:
if line.startswith('python') and line[:-1].endswith('a'):
print (line)
find_file("E://Python//p.txt")
或
def find_file(fname):
f=open(fname)
for line in f:
if line.startswith('python') and line.endswith('a\n'):
print (line)
find_file("E://Python//p.txt")