0

I am trying to open a .c file with the below content

web_test("LunchType",
         "LB=\"foodType\":\"",
         "RB=\",",
         "ORD=ALL",
         "SEARCH=ALL",
         LAST);

used the following code to open and read the content

def open_file_read_line_by_line(self,file_to_read):
    with io.open(file_to_read,"rt",encoding='utf-8') as f:
        while True:
            readfile = f.readline()
            # readfile = f.read()
            if not readfile:
                break
            yield readfile
    f.close()

when reading the second line, I get the following content

"LB=\\"foodType\\":\\"",

There is an additonal '\' infront of '\' . Can anyone suggest how can I correct this ?

Joe_12345
  • 589
  • 2
  • 7
  • 19
  • 1
    you're seeing the representation of the string. Try to `print` it, you'll see that there's only one slash (note: your snippet doesn't show how you get this output, I suppose you're putting this in a list then print the list) – Jean-François Fabre Nov 17 '17 at 16:32
  • @Jean-FrançoisFabre you were right. – Joe_12345 Nov 17 '17 at 18:13

0 Answers0