python基本模块中的对象_【python学习笔记】python中的模块,类,函数,对象,实例(与JAVA的比较)...

>>> importzipfile>>>help(zipfile)

Help on module zipfile:

NAME

zipfile- Read andwrite ZIP files.

DESCRIPTION

XXX references to utf-8need further investigation.

CLASSES

builtins.Exception(builtins.BaseException)

BadZipFile

LargeZipFile

builtins.object

ZipFile

PyZipFile

ZipInfoclassBadZipFile(builtins.Exception)|Method resolution order:|BadZipFile|builtins.Exception|builtins.BaseException|builtins.object|

|Data descriptors defined here:|

| __weakref__

| list of weak references to the object (ifdefined)|

| ----------------------------------------------------------------------

| Methods inherited frombuiltins.Exception:|

| __init__(self, /, *args, **kwargs)| Initialize self. See help(type(self)) foraccurate signature.|

| __new__(*args, **kwargs) frombuiltins.type| Create and return a new object. See help(type) foraccurate signature.|

| ----------------------------------------------------------------------

| Methods inherited frombuiltins.BaseException:|

| __delattr__(self, name, /)|Implement delattr(self, name).|

| __getattribute__(self, name, /)|Return getattr(self, name).|

| __reduce__(...)|

| __repr__(self, /)|Return repr(self).|

| __setattr__(self, name, value, /)|Implement setattr(self, name, value).|

| __setstate__(...)|

| __str__(self, /)|Return str(self).|

|with_traceback(...)| Exception.with_traceback(tb) --

| set self.__traceback__ to tb and returnself.|

| ----------------------------------------------------------------------

| Data descriptors inherited frombuiltins.BaseException:|

| __cause__

|exception cause|

| __context__

|exception context|

| __dict__

|

| __suppress_context__

|

| __traceback__

|

|args

BadZipfile= classBadZipFile(builtins.Exception)|Method resolution order:|BadZipFile|builtins.Exception|builtins.BaseException|builtins.object|

|Data descriptors defined here:|

| __weakref__

| list of weak references to the object (ifdefined)|

| ----------------------------------------------------------------------

| Methods inherited frombuiltins.Exception:|

| __init__(self, /, *args, **kwargs)| Initialize self. See help(type(self)) foraccurate signature.|

| __new__(*args, **kwargs) frombuiltins.type| Create and return a new object. See help(type) foraccurate signature.|

| ----------------------------------------------------------------------

| Methods inherited frombuiltins.BaseException:|

| __delattr__(self, name, /)|Implement delattr(self, name).|

| __getattribute__(self, name, /)|Return getattr(self, name).|

| __reduce__(...)|

| __repr__(self, /)|Return repr(self).|

| __setattr__(self, name, value, /)|Implement setattr(self, name, value).|

| __setstate__(...)|

| __str__(self, /)|Return str(self).|

|with_traceback(...)| Exception.with_traceback(tb) --

| set self.__traceback__ to tb and returnself.|

| ----------------------------------------------------------------------

| Data descriptors inherited frombuiltins.BaseException:|

| __cause__

|exception cause|

| __context__

|exception context|

| __dict__

|

| __suppress_context__

|

| __traceback__

|

|argsclassLargeZipFile(builtins.Exception)|Raised when writing a zipfile, the zipfile requires ZIP64 extensions| andthose extensions are disabled.|

|Method resolution order:|LargeZipFile|builtins.Exception|builtins.BaseException|builtins.object|

|Data descriptors defined here:|

| __weakref__

| list of weak references to the object (ifdefined)|

| ----------------------------------------------------------------------

| Methods inherited frombuiltins.Exception:|

| __init__(self, /, *args, **kwargs)| Initialize self. See help(type(self)) foraccurate signature.|

| __new__(*args, **kwargs) frombuiltins.type| Create and return a new object. See help(type) foraccurate signature.|

| ----------------------------------------------------------------------

| Methods inherited frombuiltins.BaseException:|

| __delattr__(self, name, /)|Implement delattr(self, name).|

| __getattribute__(self, name, /)|Return getattr(self, name).|

| __reduce__(...)|

| __repr__(self, /)|Return repr(self).|

| __setattr__(self, name, value, /)|Implement setattr(self, name, value).|

| __setstate__(...)|

| __str__(self, /)|Return str(self).|

|with_traceback(...)| Exception.with_traceback(tb) --

| set self.__traceback__ to tb and returnself.|

| ----------------------------------------------------------------------

| Data descriptors inherited frombuiltins.BaseException:|

| __cause__

|exception cause|

| __context__

|exception context|

| __dict__

|

| __suppress_context__

|

| __traceback__

|

|argsclassPyZipFile(ZipFile)| Class to create ZIP archives with Python library files andpackages.|

|Method resolution order:|PyZipFile|ZipFile|builtins.object|

|Methods defined here:|

| __init__(self, file, mode='r', compression=0, allowZip64=True, optimize=-1)|

| writepy(self, pathname, basename='', filterfunc=None)| Add all files from "pathname"to the ZIP archive.|

| If pathname is a package directory, search the directory and

| all package subdirectories recursively for all *.py andenter| the modules into the archive. If pathname isa plain| directory, listdir *.py andenter all modules. Else, pathname| must be a Python *.py file andthe module will be put into the| archive. Added modules are always module.pyo ormodule.pyc.| This method will compile the module.py into module.pyc if

|necessary.| If filterfunc(pathname) is given, it iscalled with every argument.| When it is False, the file or directory isskipped.|

| ----------------------------------------------------------------------

| Methods inherited fromZipFile:|

| __del__(self)| Call the "close()" method incase the user forgot.|

| __enter__(self)|

| __exit__(self, type, value, traceback)|

|close(self)| Close the file, and for mode "w" and "a"write the ending|records.|

| extract(self, member, path=None, pwd=None)| Extract a member fromthe archive to the current working directory,| using its full name. Its file information isextracted as accurately| as possible. `member'may be a filename or a ZipInfo object. You can

| specify a different directory using `path'.

|

| extractall(self, path=None, members=None, pwd=None)| Extract all members fromthe archive to the current working| directory. `path'specifies a different directory to extract to.

| `members'is optional and must be a subset of the list returned

|by namelist().|

|getinfo(self, name)| Return the instance of ZipInfo given 'name'.|

|infolist(self)| Return a list of class ZipInfo instances for files inthe|archive.|

|namelist(self)| Return a list of file names inthe archive.|

| open(self, name, mode='r', pwd=None)| Return file-like object for 'name'.|

| printdir(self, file=None)| Print a table of contents forthe zip file.|

| read(self, name, pwd=None)| Return file bytes (as a string) forname.|

|setpassword(self, pwd)| Set default password forencrypted files.|

|testzip(self)| Read all the files andcheck the CRC.|

| write(self, filename, arcname=None, compress_type=None)| Put the bytes fromfilename into the archive under the name|arcname.|

| writestr(self, zinfo_or_arcname, data, compress_type=None)| Write a file into the archive. The contents is 'data', which| may be either a 'str' or a 'bytes' instance; if it is a 'str',| it is encoded as UTF-8first.| 'zinfo_or_arcname' is either a ZipInfo instance or

| the name of the file inthe archive.|

| ----------------------------------------------------------------------

| Data descriptors inherited fromZipFile:|

| __dict__

| dictionary for instance variables (ifdefined)|

| __weakref__

| list of weak references to the object (ifdefined)|

|comment|The comment text associated with the ZIP file.|

| ----------------------------------------------------------------------

| Data and other attributes inherited fromZipFile:|

| fp =NoneclassZipFile(builtins.object)|Class with methods to open, read, write, close, list zip files.|

| z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=True)|

| file: Either the path to the file, or a file-like object.| If it is a path, the file will be opened andclosed by ZipFile.| mode: The mode can be either read "r", write "w" or append "a".|compression: ZIP_STORED (no compression), ZIP_DEFLATED (requires zlib),| ZIP_BZIP2 (requires bz2) orZIP_LZMA (requires lzma).| allowZip64: ifTrue ZipFile will create files with ZIP64 extensions when| needed, otherwise it will raisean exception when this would|be necessary.|

|Methods defined here:|

| __del__(self)| Call the "close()" method incase the user forgot.|

| __enter__(self)|

| __exit__(self, type, value, traceback)|

| __init__(self, file, mode='r', compression=0, allowZip64=True)| Open the ZIP file with mode read "r", write "w" or append "a".|

|close(self)| Close the file, and for mode "w" and "a"write the ending|records.|

| extract(self, member, path=None, pwd=None)| Extract a member fromthe archive to the current working directory,| using its full name. Its file information isextracted as accurately| as possible. `member'may be a filename or a ZipInfo object. You can

| specify a different directory using `path'.

|

| extractall(self, path=None, members=None, pwd=None)| Extract all members fromthe archive to the current working| directory. `path'specifies a different directory to extract to.

| `members'is optional and must be a subset of the list returned

|by namelist().|

|getinfo(self, name)| Return the instance of ZipInfo given 'name'.|

|infolist(self)| Return a list of class ZipInfo instances for files inthe|archive.|

|namelist(self)| Return a list of file names inthe archive.|

| open(self, name, mode='r', pwd=None)| Return file-like object for 'name'.|

| printdir(self, file=None)| Print a table of contents forthe zip file.|

| read(self, name, pwd=None)| Return file bytes (as a string) forname.|

|setpassword(self, pwd)| Set default password forencrypted files.|

|testzip(self)| Read all the files andcheck the CRC.|

| write(self, filename, arcname=None, compress_type=None)| Put the bytes fromfilename into the archive under the name|arcname.|

| writestr(self, zinfo_or_arcname, data, compress_type=None)| Write a file into the archive. The contents is 'data', which| may be either a 'str' or a 'bytes' instance; if it is a 'str',| it is encoded as UTF-8first.| 'zinfo_or_arcname' is either a ZipInfo instance or

| the name of the file inthe archive.|

| ----------------------------------------------------------------------

|Data descriptors defined here:|

| __dict__

| dictionary for instance variables (ifdefined)|

| __weakref__

| list of weak references to the object (ifdefined)|

|comment|The comment text associated with the ZIP file.|

| ----------------------------------------------------------------------

| Data andother attributes defined here:|

| fp =NoneclassZipInfo(builtins.object)| Class with attributes describing each file inthe ZIP archive.|

|Methods defined here:|

| FileHeader(self, zip64=None)| Return the per-file header as a string.|

| __init__(self, filename='NoName', date_time=(1980, 1, 1, 0, 0, 0))|

| ----------------------------------------------------------------------

|Data descriptors defined here:|

|CRC|

|comment|

|compress_size|

|compress_type|

|create_system|

|create_version|

|date_time|

|external_attr|

|extra|

|extract_version|

|file_size|

|filename|

|flag_bits|

|header_offset|

|internal_attr|

|orig_filename|

|reserved|

|volume

error= classBadZipFile(builtins.Exception)|Method resolution order:|BadZipFile|builtins.Exception|builtins.BaseException|builtins.object|

|Data descriptors defined here:|

| __weakref__

| list of weak references to the object (ifdefined)|

| ----------------------------------------------------------------------

| Methods inherited frombuiltins.Exception:|

| __init__(self, /, *args, **kwargs)| Initialize self. See help(type(self)) foraccurate signature.|

| __new__(*args, **kwargs) frombuiltins.type| Create and return a new object. See help(type) foraccurate signature.|

| ----------------------------------------------------------------------

| Methods inherited frombuiltins.BaseException:|

| __delattr__(self, name, /)|Implement delattr(self, name).|

| __getattribute__(self, name, /)|Return getattr(self, name).|

| __reduce__(...)|

| __repr__(self, /)|Return repr(self).|

| __setattr__(self, name, value, /)|Implement setattr(self, name, value).|

| __setstate__(...)|

| __str__(self, /)|Return str(self).|

|with_traceback(...)| Exception.with_traceback(tb) --

| set self.__traceback__ to tb and returnself.|

| ----------------------------------------------------------------------

| Data descriptors inherited frombuiltins.BaseException:|

| __cause__

|exception cause|

| __context__

|exception context|

| __dict__

|

| __suppress_context__

|

| __traceback__

|

|args

FUNCTIONS

is_zipfile(filename)

Quickly seeif a file isa ZIP file by checking the magic number.

The filename argument may be a fileor file-like object too.

DATA

ZIP_BZIP2= 12ZIP_DEFLATED= 8ZIP_LZMA= 14ZIP_STORED=0__all__ = ['BadZipFile', 'BadZipfile', 'error', 'ZIP_STORED', 'ZIP_DEF...

FILE

d:\python34\lib\zipfile.py

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值