Namespaces
Variants
Actions

Archived:How to create and extract zip archives using PySymbian

Jump to: navigation, search
Archived.png
Aquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

Acredita-se que este artigo ainda seja válido no contexto original (quando ele foi escrito)


Article Metadata

Tested with
Devices(s): Nokia N95, Nokia E90

Compatibility
Platform(s): S60 1st Edition, S60 2nd Edition, S60 3rd Edition

Platform Security
Capabilities: )

Article
Keywords: zipfile
Created: bogdan.galiceanu (02 Jun 2008)
Last edited: hamishwillee (08 May 2013)

Contents

Overview

This article shows how to create and extract zip archives in Python.

Source code

Creating an archive

import zipfile
 
 
#Create a new archive
a = zipfile.ZipFile("C:\\x.zip", 'w')
#Add the file "x.sis" to the archive
a.write("C:\\x.sis")
#Close the archive
a.close()

Appending to an existing archive

import zipfile
 
 
#Open an archive
a = zipfile.ZipFile("C:\\x.zip", 'a')
#Add the file "y.sis" to the archive
a.write("C:\\y.sis")
#Close the archive
a.close()

Extracting the contents of an archive

import zipfile
 
 
#Open the archive in read mode
a = zipfile.ZipFile("C:\\x.zip", 'r')
#Extract every file from it
for i in a.namelist():
b = open("C:\\"+i, 'wb')
b.write(a.read(i))
b.close()
#Close the archive
a.close()

Postconditions

The operations described above are performed.

Additional information

More information about the zipfile library can be found here.

This page was last modified on 8 May 2013, at 08:27.
166 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved