python - codec can't encode character: character maps to -


Im trying to read a docx file in Python 2.7 with this code:

  import docx Document = docx.Document ('sim_dir_administrativo.docx') docText = '\ n \ n'. (Paragraph text for paragraph in the document). (Code '' utf-8 ''). Paragraph])   

And then I am trying to decode the string inside the file with this code because I have some special characters (like à pounds):

  print docText.decode ("UTF-8")   

But, I am getting this error:

  return codecs .charmap_encode (input, errors, encoding_map) Unicode encoded error: 'charmap' codec character U can not encode in '494457': Character Maps can be encapsulated with & lt; Undefined & gt;   

How can I solve it?

Print functions are only printed characters that are in your local encoding You can find that What is with sys.stdout.encoding To print with special characters, you must first encode it in your local encoding.

  # - * - Coding: UTF-8 - * - Import system prints sys.stdout.encoding Print and "Stoker" .encode (sys.stdout.encoding, Errors = 'Replacement') Print and "Ð¡Ñ ?? оÐμÑ ?? кÐμÑ ??" Signing (sys.stdout.encoding, errors = 'substitution')   

This code snippet took place.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -