我有一个文件包含
"1111 1111 1111 // google
1111 1111 1111 // google talk browser
1111 1111 1111 // google talks
1111 1111 1111 // google talk"
我只想打印“// google talk”相关行(仅第 4 行)
像这样试过这不起作用......
with open('file.txt', 'r') as handle:
for index, line in enumerate(handle, 1):
if line.strip() == 'talk':
print 'Match found on line', index