如何使用Python 3中的帮助功能查看文件处理函数文档?

时间:2014-04-03 13:37:53

标签: python python-3.x file-io

我尝试使用help()函数查看Python空闲内的文件处理函数文档。

到目前为止,我已经完成并获得了以下内容:

>>> fh = open('file.txt', 'w')
>>> help(fh.seek)
Help on built-in function seek:

seek(...)

如何获取文档?

1 个答案:

答案 0 :(得分:1)

>>> import io
>>> help(io.FileIO.seek)

返回:

Help on method_descriptor:

seek(...)
    seek(offset: int[, whence: int]) -> None.  Move to new file position.

    Argument offset is a byte count.  Optional argument whence defaults to
    0 (offset from start of file, offset should be >= 0); other values are 1
    (move relative to current position, positive or negative), and 2 (move
    relative to end of file, usually negative, although many platforms allow
    seeking beyond the end of a file).
    Note that not all file objects are seekable.
(END) 

(Python 3.4.0)