test_csv.py 文件源码

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

项目:oil 作者: oilshell 项目源码 文件源码
def test_space_dialect(self):
        class space(csv.excel):
            delimiter = " "
            quoting = csv.QUOTE_NONE
            escapechar = "\\"

        fd, name = tempfile.mkstemp()
        fileobj = os.fdopen(fd, "w+b")
        try:
            fileobj.write("abc def\nc1ccccc1 benzene\n")
            fileobj.seek(0)
            rdr = csv.reader(fileobj, dialect=space())
            self.assertEqual(rdr.next(), ["abc", "def"])
            self.assertEqual(rdr.next(), ["c1ccccc1", "benzene"])
        finally:
            fileobj.close()
            os.unlink(name)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号