python 3.2 UnicodeEncodeError: 'charmap' codec can't encode character '\u2013' in position 9629: character maps to

前端 未结 4 632
故里飘歌
故里飘歌 2021-01-28 06:05

I\'m trying to make a script that gets data out from an sqlite3 database, but I have run in to a problem.

The field in the database is of type text and the contains a ht

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-28 06:38

    Maybe a little late to reply. I happen to run into the same problem today. I find that on Windows you can change the console encoder to utf-8 or other encoder that can represent your data. Then you can print it to sys.stdout.

    First, run following code in the console:

    chcp 65001
    set PYTHONIOENCODING=utf-8
    

    Then, start python do anything you want.

提交回复
热议问题