# _*_ coding: utf-8 _*_

import zipfile
import shutil
import os
print os.getcwd()
basedir = os.path.dirname(__file__)

print os.path.dirname(os.path.dirname(__file__))


def unzip_file(zipfilename,unziptodir):
    if not os.path.exists(unziptodir):
        os.mkdir(unziptodir,0777)
    zfobj = zipfile.ZipFile(zipfilename)
    for name in zfobj.namelist():
        name = name.replace('\\','/')
        if name.endswith('/'):
            print name
            os.mkdir(os.path.join(unziptodir,name))
        else:
            ext_filename = os.path.join(unziptodir,name)
            ext_dir = os.path.dirname(ext_filename)
            if not os.path.exists(ext_dir):
                os.mkdir(ext_dir,0777)
            outfile = open(ext_filename,'wb')
            outfile.write(zfobj.read(name))
            outfile.close()
def deledir():
    current_path = os.path.split(os.path.realpath(__file__))[0]
    current_filelist = os.listdir(current_path)
    for f in current_filelist:
        if os.path.isdir(f):
            real_folder_path = os.path.join(current_path,f)
            try:
                for root,dirs,files in os.walk(real_folder_path):
                    for name in files:
                        del_file = os.path.join(root,name)
                        os.remove(del_file)
                    shutil.rmtree(real_folder_path)
if __name__ == '__main__':
    
    unzip_file(r'd:\temp\Android.zip',r'E:\temp\liuzhi')

    

 

相关文章:

  • 2022-12-23
  • 2022-01-24
  • 2022-12-23
  • 2021-11-21
  • 2021-08-10
  • 2022-01-06
  • 2021-06-04
猜你喜欢
  • 2021-11-21
  • 2021-11-30
  • 2022-01-27
  • 2022-12-23
  • 2021-12-08
相关资源
相似解决方案