简体   繁体   中英

python error codecs.charmap_encode(input,errors,encoding_map) UnicodeEncodeError: 'charmap' codec can't encode characters

I am running sparql query to people's name from dbpedia for a give movie After getting data I am displaying name as well as putting into Mysql I am getting normal names but at one pointit threw an error

I got an error:

Traceback (most recent call last):
  File "TestSparql.py", line 172, in <module>
    print person_Name
  File "C:\Python27\Lib\encodings\cp437.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode characters in position 16-21: character maps to <undefined> 

could some one explain what this error means and why it might have come?

That error means that Python is not able to encode as unicode your strings. Further details at http://wiki.python.org/moin/UnicodeEncodeError

In order to help you, many details are missing:

  • SPARQL Python implementation you are using to query DBpedia
  • The printing code that produces such error
  • Some environment details (you charset configuration and so on)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM