使用zipfile模块,我创建了一个脚本来提取我的归档文件,但是这个方法会破坏除txt文件之外的所有内容。在
def unzip(zip):
filelist = []
dumpfold = r'M:\SVN_EReportingZones\eReportingZones\data\input\26012012'
storage = r'M:\SVN_EReportingZones\eReportingZones\data\input\26012012__download_dump'
file = storage + '\\' + zip
unpack = dumpfold + '\\' + str(zip)
print file
try:
time.sleep(1)
country = str(zip[:2])
countrydir = dumpfold + '\\' + country
folderthere = 0
if exists(countrydir):
folderthere = 1
if folderthere == 0:
os.makedirs(countrydir)
zfile = zipfile.ZipFile(file, 'r')
## print zf.namelist()
time.sleep(1)
shapepresent = 0
这里我有一个问题-通过读写压缩数据,zipfile命令似乎使它无法被相关程序使用-我试图解压shapefile以在ArcGIS中使用。。。在
^{pr2}$可以用系统命令调用WinRar并让它帮我解包吗?干杯,亚历克斯
编辑
使用wb方法后,它适用于我的大多数文件,但有些文件仍在损坏。当我使用winRar手动解压有问题的文件时,它们会正确加载,并且文件大小也会更大。在
有人能告诉我加载winRar的方向吗?在
为了回答你问题的第二部分,我建议使用envoy library。使用winRar与特使:
在没有特使的情况下:
^{pr2}$您正在以文本模式打开文件。尝试:
b
以二进制模式打开文件,在这种模式下,运行库不尝试进行任何换行转换。在相关问题 更多 >
编程相关推荐