• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

在目录下查找图片文件并拷贝到指定目录


Recommended Posts

代码如下:

#!/usr/bin/env python3

导入操作系统

导入技能

#遍历目录下的所有文件

对于os.walk(' . '))中的根、子目录、文件): #其中根为当前根目录,子转盘为子目录,文件为文件

对于文件:中的文件

如果文件:中有"巴布亚新几内亚"

source_file=os.path.join(root,file) #将文件和目录拼接起来

target_file='./png' #将要拷贝到的目录

打印(源文件)

shutil.copy(源文件,目标文件)

2q4arwpm20h4218.png

Link to comment
Share on other sites