# _*_ 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 : Donate | Close |