1

I've scratched my head for hours on this. Upon research it looks like I can't output something that's not encoded. I've tried pretty much everything. I've tried re-encoding linees, formatted, item, final_data. None of this worked. I've looked at probably every single SOF article on this issue and I have found nothing. It's very weird.

So I have:

for item in final_data:
    export = open(finalanswer , 'w')
    linees = item.text.encode('utf-8')
    formatted = linees.decode().split('00000')
    linees = item.text.encode('utf-8')
    export.write("\n".join(map(lambda x: str(x), final_data)) + "\n")
    export.close
    print("Complete. Bye")

Here's the error that this fetched back, not sure why this is not working...

Traceback (most recent call last):
File "D:\Scripts\Python\Autorunner.py", line 152, in <module>
export.write("\n".join(map(lambda x: str(x), final_data)) + "\n")
File "C:\Program Files\Python36\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 85234-85238: character maps to <undefined>

Would someone possibly be able to help?

Josh Lee
  • 171,072
  • 38
  • 269
  • 275
Ryan Davis
  • 59
  • 1
  • 2

0 Answers0