fileinput.input函数 是对 fileinput.FileInput 类的再封装

发布时间 2023-06-20 11:07:21作者: sangern
def input(files=None, inplace=False, backup="", bufsize=0,
          mode="r", openhook=None):
    """Return an instance of the FileInput class, which can be iterated.

    The parameters are passed to the constructor of the FileInput class.
    The returned instance, in addition to being an iterator,
    keeps global state for the functions of this module,.
    """
    global _state
    if _state and _state._file:
        raise RuntimeError("input() already active")
    _state = FileInput(files, inplace, backup, bufsize, mode, openhook)
    return _state

  fileinput.input函数 是对 fileinput.FileInput 类的再封装

 

fileinput.FileInput 类是对 open 函数的再封窗