python编程快速上手之第9章实践项目参考答案(9.8.1)
import os,shutil
newfolder='C:\\delicious\\test'
sourcefolder='C:\\delicious'
os.chdir(sourcefolder)
for folderName, subfolders, filenames in os.walk(sourcefolder):
#print (filenames)
for item in filenames:
if item.endswith('.txt'):
#print(item)
shutil.copy(item , newfolder)
print ('Copy '+ item +' to '+newfolder )
#else:
#print('NONE')
posted on 2017-04-16 11:07 flying-wyf 阅读(164) 评论(1) 编辑 收藏 举报