csvreader.py 文件源码

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

项目:datatest 作者: shawnbrown 项目源码 文件源码
def _get_file_object(csvfile, encoding=None):
        if isinstance(csvfile, str):
            assert encoding, 'encoding required for file path'
            return open(csvfile, 'rt', encoding=encoding, newline='')  # <- EXIT!

        if hasattr(csvfile, 'mode'):
            assert 'b' not in csvfile.mode, "File must be open in text mode ('rt')."
        elif issubclass(csvfile.__class__, io.IOBase):
            assert issubclass(csvfile.__class__, io.TextIOBase), ("Stream object must inherit "
                                                                  "from io.TextIOBase.")
        return csvfile
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号