目前,我正在尝试通过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)