#-*- coding:utf-8 -*-
'''
Created on 2012-8-22
'''
try:
JAP=open("F:\\pythonwork\\jap.txt","r")
CHN=open("F:\\pythonwork\\chn.txt","r")
UTF=open("F:\\pythonwork\\utf.txt","w")
# jap_text=JAP.readline()
# chn_text=CHN.readline()
for j in JAP.readlines():
#先decode成UTF-16,再encode成UTF-8
jap_text_utf8=j.decode("SHIFT_JIS").encode("UTF-8")
UTF.write(jap_text_utf8)
#不轉成utf-8也能夠
for c in CHN.readlines():
chn_text_utf8=c.decode("GB2312").encode("UTF-8")
#編碼方式大小寫都行utf-8也同樣
UTF.write(chn_text_utf8)
UTF.close()
except IOError,e:
print "open file error",e
print 'write is ok'