小编use*_*027的帖子

如何修复''UnicodeDecodeError:'charmap'编解码器无法解码位置29815中的字节0x9d:字符映射到<undefined>''?

目前,我正在尝试通过Spyder IDE/GUI使用填充了信息的文本文件对Python 3程序进行一些操作.但是,在尝试读取文件时,我收到以下错误:

  File "<ipython-input-13-d81e1333b8cd>", line 77, in <module>
    parser(f)

  File "<ipython-input-13-d81e1333b8cd>", line 18, in parser
    data = infile.read()

  File "C:\ProgramData\Anaconda3\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 0x9d in position 29815: character maps to <undefined>
Run Code Online (Sandbox Code Playgroud)

该计划的代码如下:

import os

os.getcwd()

import glob
import re
import sqlite3
import csv

def parser(file):

    # Open a TXT file. Store all articles in a list. Each article is an item
    # of the list. Split articles based on the …
Run Code Online (Sandbox Code Playgroud)

python sqlite unicode file-io decode

10
推荐指数
5
解决办法
3万
查看次数

标签 统计

decode ×1

file-io ×1

python ×1

sqlite ×1

unicode ×1