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)
评论列表
文章目录