在python中将串联值传递给zipfile方法

时间:2018-06-19 19:34:47

标签: python concatenation zipfile

我是python的初学者。在将函数参数与字符串连接起来并将其传递给Zipfile时,我遇到了一个问题。请帮助我,

import zipfile,os
from xml.dom import minidom
def zipFunc(output)
absPath='E:\'+output+'.zip'
fName='package'
with zipfile.ZipFile(absPath, 'r') as zip:
data=zip.read(fName+'/manifest.txt')
xmldoc =minidom.parseString(data)
itemlist = xmldoc.getElementsByTagName('value') 
for s in itemlist :
        if s.attributes['name'].value=="version":
            print s.firstChild.nodeValue

最终的串联路径应为

E:\pyauto\package.zip

但是我面临以下错误,

with zipfile.ZipFile(absPath, 'r') as zip:
File "C:\Python27\lib\zipfile.py", line 756, in __init__
self.fp = open(file, modeDict[mode])
IOError: [Errno 22] invalid mode ('rb') or filename: 
u'E:\\pyauto\\package\r\x07.zip'

0 个答案:

没有答案