Zip file,zipfile,import zipfi
Zip file,zipfile,import zipfi
import zipfiledef data_to_zip_direct(z, data, name): import time zinfo = zipfile.ZipInfo(name, time.localtime()[:6]) z.writestr(zinfo, data)def data_to_zip_indirect(z, data, name): import os flob = open(name, 'wb') flob.write(data) flob.close() z.write(name) os.unlink(name)zz = zipfile.ZipFile('z.zip', 'w', zipfile.ZIP_DEFLATED)data = 'four score\nand seven\nyears ago\n'data_to_zip_direct(zz, data, 'direct.txt')data_to_zip_indirect(zz, data, 'indirect.txt')zz.close()
- Demonstrates reading from a text file,,# print 'Ope
- Reading characters from the file.,readingcharacters,pr
- Reading characters from a line.,readingcharacters,prin
- Print out a date, given year, month, and day as numbers,
- Define and ouuput string: 8-bit, 1-byte, 2-byte and 4-by
- Random int value,randomintvalue,import rando
热门文章:
相关内容
- Demonstrates reading from a text file,,# print 'Ope
- Reading characters from the file.,readingcharacters,print '\nRea
- Reading characters from a line.,readingcharacters,print '\nRea
- Print out a date, given year, month, and day as numbers,givennumber
- Define and ouuput string: 8-bit, 1-byte, 2-byte and 4-byte,ouuput1-
- Random int value,randomintvalue,import rando
- Reflection: Find the data type,reflectionfind,from types i
- Sort stdin input lines and send result to stdout,stdinstdout,import
- sys.stdin.readline() with out error check,,import sys,
- Link Python system error stream into a file,pythonstream,import sys
评论关闭