0

I'm parsing a file that's written in UTF16-LE for fairly simple matches and none of them seem to trigger. For example, I have the following code.

with open(filepath) as f:
   for line in f:
      if 'TEST_CASE' in line:
         print(line)

Is there a good way to check the lines in the file for matches without altering the file itself?

angusiguess
  • 639
  • 5
  • 11

1 Answers1

1

As per my comment codecs.open('filename', encoding='utf-16-le')

Jon Clements
  • 138,671
  • 33
  • 247
  • 280