记录:2018/9/4

# _*_ coding:utf-8_*_
#遍历dirname="D:\\"下的所有文件,找出image_name图片
def findKeyFile(dirname,image_name):
    global image_srcpath
    global judge_path
    for r,d,f in os.walk(dirname,topdown=False):
	    for n in f:
		    if(n.find(image_name)>=0):
			    image_srcpath=os.path.join(r,n)
			    judge_path=os.path.join("D:\\photo",n)
			    return 1
				
#将image拷贝至dst="D:\\photo"目标文件夹中
def copyimage(image_srcpath,dst):
        if os.path.exists(dst):
            shutil.copy(os.path.join(image_srcpath),dst)
        else:
            os.makedirs(dst)
            shutil.copy(os.path.join(image_srcpath),dst)

import os,string
import re,shutil
	
reg = re.compile(r'(\./photo\\)(.+g)(\s)(.+)')
dirname="D:\\"
testpath="D:\\test_special"#testpath="D:\\test"
dst="D:\\photo"
i=0
for r,d,f in os.walk(testpath,topdown=False):
    for n in f:
	    text_path=os.path.join(r,n)
	    file_object = open(text_path,'r',encoding='utf-8',errors='ignore') #file_object = open(text_path,'r')
	    # content = file_object.read().decode('gbk')
	    f=open("D:/testsltest/sltext.txt","a+")	
	    f.write("\n"+text_path+"\n")#标记出处		
	    try: 
	        for line in file_object:
	            try:
	                if '-' in reg.match(line).group(4):
	                    gp2=reg.match(line).group(2)
	                    print(gp2)
	                    if findKeyFile(dirname,gp2)==1:#如果在dirname文件夹下找到了gp2图片
	                        if(os.path.exists(judge_path)==False):	#(防止重复复制图片)			
	                            copyimage(image_srcpath,dst)#则将图片复制到photo中去
	                            print(gp2)
	                            f.write(gp2+"\n")#带"-"的图片文件名写入sltext	  
	                            i=i+1
	            except AttributeError as e:
	                pass
	    finally:
	        file_object.close()
	    print(i)

 

 

 

 

G

M

T

 

 

 Detect languageAfrikaansAlbanianAmharicArabicArmenianAzerbaijaniBasqueBelarusianBengaliBosnianBulgarianCatalanCebuanoChichewaChinese (Simplified)Chinese (Traditional)CorsicanCroatianCzechDanishDutchEnglishEsperantoEstonianFilipinoFinnishFrenchFrisianGalicianGeorgianGermanGreekGujaratiHaitian CreoleHausaHawaiianHebrewHindiHmongHungarianIcelandicIgboIndonesianIrishItalianJapaneseJavaneseKannadaKazakhKhmerKoreanKurdishKyrgyzLaoLatinLatvianLithuanianLuxembourgishMacedonianMalagasyMalayMalayalamMalteseMaoriMarathiMongolianMyanmar (Burmese)NepaliNorwegianPashtoPersianPolishPortuguesePunjabiRomanianRussianSamoanScots GaelicSerbianSesothoShonaSindhiSinhalaSlovakSlovenianSomaliSpanishSundaneseSwahiliSwedishTajikTamilTeluguThaiTurkishUkrainianUrduUzbekVietnameseWelshXhosaYiddishYorubaZulu

 

AfrikaansAlbanianAmharicArabicArmenianAzerbaijaniBasqueBelarusianBengaliBosnianBulgarianCatalanCebuanoChichewaChinese (Simplified)Chinese (Traditional)CorsicanCroatianCzechDanishDutchEnglishEsperantoEstonianFilipinoFinnishFrenchFrisianGalicianGeorgianGermanGreekGujaratiHaitian CreoleHausaHawaiianHebrewHindiHmongHungarianIcelandicIgboIndonesianIrishItalianJapaneseJavaneseKannadaKazakhKhmerKoreanKurdishKyrgyzLaoLatinLatvianLithuanianLuxembourgishMacedonianMalagasyMalayMalayalamMalteseMaoriMarathiMongolianMyanmar (Burmese)NepaliNorwegianPashtoPersianPolishPortuguesePunjabiRomanianRussianSamoanScots GaelicSerbianSesothoShonaSindhiSinhalaSlovakSlovenianSomaliSpanishSundaneseSwahiliSwedishTajikTamilTeluguThaiTurkishUkrainianUrduUzbekVietnameseWelshXhosaYiddishYorubaZulu

 

 

 

 

 

 

 

 

 

Text-to-speech function is limited to 200 characters

 

 

 

Options : History : Feedback : DonateClose
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值