0

I am trying to read a file, (password list), I get the following error:

Traceback (most recent call last):
  File "C:\Users\ayden\Documents\2.1 Hacks\Python\PowerUp\FTPCracker.py", line 25, in <module>
    passwords = file.read()
  File "C:\Users\ayden\AppData\Local\Programs\Python\Python35-32\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 1911885: character maps to <undefined>

Is it too big or is there some weird unallowed character?

1 Answers1

0

Check the encoding of the file and then specify the same while opening it.

For eg if it's UTF8 encoded, then do:

file = open(filename, encoding="utf8")
Chankey Pathak
  • 21,187
  • 12
  • 85
  • 133
  • The text files encoding is "ANSI", when I use that it says invalid encoding type. –  Jun 05 '17 at 08:13
  • And when I try UTF-8 it says "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf1 in position 5079963: invalid continuation byte" –  Jun 05 '17 at 08:14
  • 1
    Aha! I tried Latin 1 and boom! It worked, thanks for the help :) –  Jun 05 '17 at 08:16