Why do I get extra \'s when I use csv_writer?

38 Views Asked by At
import csv

rows = [["Line 5"], ["4 1.66 0 0 ! x1, x2, x3, x4"]]
        
# opening the CSV file
with open('testing.txt', 'w', newline='') as file:

# writing the CSV file
  writer = csv.writer(file, quotechar='"', quoting=csv.QUOTE_NONE, escapechar='\\')
  writer.writerows(rows)

Result:

Line 5
4 1.66 0 0 ! x1\, x2\, x3\, x4

Why there are these backslashes after x1, x2 and x3? How can I get rid of them?

0

There are 0 best solutions below