文件编码问题~通解

f = file(...)
t = open(..,'w')
t.write(f.read())
有时候会报错或者写入t中时成乱码
这些都是因为编码不统一造成
有没有一般性的方法解决这种问题呢

For simple pass-through read-write, why not use binary mode? --

# Note: just for illustration, this naive approach breaks when
# the input file is larger than your physical memory
fp = open('input', 'rb')
tp = open('output', 'wb')
tp.write(fp.read())

Jerry