filesys.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:srctools 作者: TeamSpen210 项目源码 文件源码
def open_str(self, name: str, encoding='utf8'):
        """Open a file in unicode mode or raise FileNotFoundError.

        The return value is a StringIO in-memory buffer.
        """
        with self:
            # File() calls with the VPK object we need directly.
            if isinstance(name, VPKFile):
                file = name
            else:
                try:
                    file = self._ref[name]
                except KeyError:
                    raise FileNotFoundError(name)
            # Wrap the data to treat it as bytes, then
            # wrap that to decode and clean up universal newlines.
            return io.TextIOWrapper(io.BytesIO(file.read()), encoding)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号