我想用空格替換所有的標籤,所以我可以把我的昏迷分離文本放在另一個文件中的一行。現在,我的代碼如下所示:UnicodeDecodeError由python正則表達式
from __future__ import print_function
import re
import ast
f = open('sample_test.txt', 'r')
g = open('sample_test1.txt', 'w')
for line in f:
c = re.sub(r'\R', r' ', line.rstrip())
print (c, file = g)
f.close()
現在的問題是,我得到這個錯誤:
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 1944: character maps to <undefined>
錯誤指向哪一行? –