## page was renamed from MicroProj/2008-03-03 ##language:zh #pragma section-numbers on ''' 含有章节索引的 *PUG 文章通用模板 ''' ::-- ZoomQuiet [<<DateTime(2008-03-03T15:18:17Z)>>] <<TableOfContents>> ## 默许导航,请保留 <<Include(CPUGnav)>> = 文件编码问题~通解 = {{{#!python f = file(...) t = open(..,'w') t.write(f.read()) }}} * 有时候会报错或者写入t中时成乱码 * 这些都是因为编码不统一造成 * 有没有一般性的方法解决这种问题呢 For simple pass-through read-write, why not use binary mode? -- {{{#!python # 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` ##= 反馈 =