我有这样的纯文本,这是APUE https://justpaste.it/68ah7的第07章
尝试打开时
In [79]: fd = open("07.org", "r+")
In [80]: text = fd.read()
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
<ipython-input-80-7eca0a263a1d> in <module>
----> 1 text = fd.read()
~/anaconda3/lib/python3.7/codecs.py in decode(self, input, final)
320 # decode input (taking the buffer into account)
321 data = self.buffer + input
--> 322 (result, consumed) = self._buffer_decode(data, self.errors, fi
nal)
323 # keep undecoded input until the next call
324 self.buffer = data[consumed:]
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 60249: in
valid start byte
它表明问题出在60249
我去了很远的地方char-char 60249
最后一句话是
continues the discussion of resource limits, after we've covered signals.
信号后的点是59848
有趣的是,当检查字符为64895时。
In [95]: !wc -c 07.org
64895 07.org
59848和64895之间的字符是真空字符。
尝试:
!cut -c59848-59848
这将立即清除我的屏幕,并将命令行向下移动到底部。