Simple Task - Search Keywords in Files of Certain Type under Run Directory

If any hit, print file name.

# Keywords is case-sensitive.

import os

print(os.getcwd())

keywords= "Keywords"

for file in os.listdir():
	if file.endswith('.xml'):
		for line in open(os.getcwd()+"\\"+file, 'r'):
			if keywords in line:
				print (file)	
				break

  

posted @ 2020-12-30 19:21  q4zs  阅读(99)  评论(0)    收藏  举报