我正在设置一个脚本来根据文件中包含的文本合并PDF。我在这里的问题是“小提琴I”也包含在“小提琴II”中,并且“中音萨克斯管I”也包含在“中音萨克斯管II”中。我该如何设置,以便tempList只包含来自“Violin I”的条目并排除“Violin II”,反之亦然?分离其他地方包含的字符串
pdfList = ["01 Violin I.pdf", "02 Violin I.pdf","01 Violin II.pdf", "02 Violin II.pdf", ]
instruments = ["Soprano", "Tenor", "Violin I", "Violin II", "Viola", "Cello", "Contrabass", "Alto Saxophone I", "Alto Saxophone II", "Tenor Saxophone", "Baritone Saxophone"]
# create arrays for each instrument that can be used for merging/organization
def organizer():
for fileName in pdfList:
for instrument in instruments:
tempList = []
if instrument in fileName:
tempList.append(fileName)
print tempList
print pdfList
organizer()
PDF是否总是像这样命名? IE浏览器。 '号码+仪表+ .pdf'。或者我们是否应该假定PDF可以有任何包含该工具的名称? – woemler 2013-03-23 16:22:39
是的,PDFs将始终采用格式“(初始数字)+(一些文本)+(仪器)+ .pdf – jumbopap 2013-03-23 16:23:37