1

Here is the line that causes the error:

emner = browser.find_element_by_link_text('Armbåndsure og lommeure')

And the output:

  File "test.py", line 96
SyntaxError: Non-UTF-8 code starting with '\xe5' in file test.py on line 96, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

I need to have this "å" in my script there is no way around it, I cant replace it. How do I "allow" it to be in my script. I know its something about unicode, but I dont know that much about it. So I thought a kind person would help me out here on stack overflow.

Thanks in advance!

Sebastian Nielsen
  • 3,835
  • 5
  • 27
  • 43

1 Answers1

3

You have saved your file in a non-UTF8 encoding, but Python 3 interprets files as UTF8-encoded by default.

Either save the file as UTF8 from whatever text editor you are using, or add the line # coding: latin-1 as the first or second line in your file.

If you are unable to do either, you can replace the non-ASCII text with an ASCII-only escape sequence: 'Armb\xe5ndsure og lommeure'

Mark Tolonen
  • 166,664
  • 26
  • 169
  • 251
Robᵩ
  • 163,533
  • 20
  • 239
  • 308