我正在尝试格式化文件以便可以将其插入数据库,该文件最初是压缩的,大约 1.3MB 大。每行看起来像这样:
398,%7Enoniem+001%7E,543,480,7525010,1775,0
这就是解析这个文件的代码的样子:
Village = gzip.open(Root+'\\data'+'\\' +str(Newest_Date[0])+'\\' +str(Newest_Date[1])+'\\' +str(Newest_Date[2])\
+'\\'+str(Newest_Date[3])+' village.gz');
Village_Parsed = str
for line in Village:
Village_Parsed = Village_Parsed + urllib.parse.unquote_plus(line);
print(Village.readline());
当我运行程序时,我收到此错误:
Village_Parsed = Village_Parsed + urllib.parse.unquote_plus(line);
文件“C:\Python31\lib\urllib\parse.py”,第 404 行,in unquote_plus string = string.replace('+', ' ') TypeError: expected an object with the buffer interface
知道这里有什么问题吗?在此先感谢您的帮助:)