试验程序为:通过影藏后缀名,取得指定目录下的指定文件
import os
import sys
startdir = '/Users/./'
for dirpath,dirnames,filenames in os.walk(startdir):
for filename in filenames:
if os.path.splitext(filename)[1] == '.docx':
filepath = os.path.join(dirpath,filename)
print('file:' + filepath)
打开MAC终端,输入:
python /Users/./1.py