import os file_path = input('Please enter the directory path you want to explore: ') target = input('please enter the key word you want to find: ') def file_location(file_path): #定义寻找目标文件夹内的后缀为'.txt'的文件 os.chdir(file_path) content_list = os.listdir(os.curdir) for each in content_list: if os.path.splitext(each)[1] == '.txt'
python针对指定目录内的文本文件的关键字搜索
最新推荐文章于 2023-07-12 23:02:55 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)