memfile.py 文件源码

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

项目:ml-utils 作者: LinxiFan 项目源码 文件源码
def __init__(self, file_path, mode, data_fmt, convert_type=None):
        """
        Args:
          file_path
          mode: 'w', 'r', or 'a'. Automatically append 'b' to the mode.
          data_fmt: see https://docs.python.org/2/library/struct.html
            i - int; I - unsigned int; q - long long; Q - unsigned long long
            f - float; d - double; s - string; c - char; ? - bool
            b - signed char; B - unsigned char; h - short; H - unsigned short.
            3i - tuple of 3 ints; 'ifb' - tuple of int, float, bool
          convert_type: if you write int, file.read() will return a tuple (3,)
              use convert_return to return convert_return(*read) instead.
        """
        self.data_fmt = data_fmt
        self._size = struct.calcsize(data_fmt)
        self.convert_type = convert_type
        mode = self._get_mode(mode)

        AbstractFile.__init__(self, file_path, mode)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号