def _py2_get_file_object(csvfile, encoding):
if isinstance(csvfile, str):
return open(csvfile, 'rb') # <- EXIT!
if hasattr(csvfile, 'mode'):
assert 'b' in csvfile.mode, ("When using Python 2, file must "
"be open in binary mode ('rb').")
elif issubclass(csvfile.__class__, io.IOBase):
assert not issubclass(csvfile.__class__, io.TextIOBase), ("When using Python 2, "
"must use byte stream "
"(not text stream).")
return csvfile
评论列表
文章目录