对于Python2.7,请
io.open()在两个位置使用。
import ioimport shutilwith io.open('/etc/passwd', encoding='latin-1', errors='ignore') as source: with io.open('/tmp/goof', mode='w', encoding='utf-8') as target: shutil.copyfileobj(source, target)上面的程序在我的电脑上运行没有错误。



