Skip to content

Instantly share code, notes, and snippets.

@zhangchunlin
Created March 11, 2016 00:48
Show Gist options
  • Select an option

  • Save zhangchunlin/abf1d76648910fa90855 to your computer and use it in GitHub Desktop.

Select an option

Save zhangchunlin/abf1d76648910fa90855 to your computer and use it in GitHub Desktop.
def test19():
src_fpath = "gbk.txt"
dst_fpath = "utf8.txt"
dstf = open(dst_fpath,"w")
for line in open(src_fpath):
try:
dstf.write(line.decode("gbk").encode("utf8"))
except Exception as e:
print "error when handle '%s': '%s'"%(repr(line),e)
if __name__ == '__main__':
test19()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment