Copy CodeThe code is as follows:
##########################
# #
# to avoid truncating Chinese characters #
# file requirement is Unicode encoding #
# TXT file Save As dialog box below with drop-down box, optional #
# Storage Encoding Format #
# #
##########################
Import OS
Import struct
filename = str (raw_input ("Please enter a old file name:"))
Filenamepre = str (raw_input ("Please enter a new file name prefix:"))
Count = 0
FileCount = 0
Maxcount = 20
NewFileName = repr (filecount) + '. txt '
Oldfile = open (filename, ' RB ')
Bfirst = True
While True:
s = Oldfile.read (512*8-4)
If not s:
Exit ()
FileCount = FileCount + 1
NewFileName = Filenamepre + repr (filecount). Zfill (2) + '. txt '
NewFile = open (NewFileName, ' WB ')
If not bfirst:
BES = 0XFEFF
Newfile.write (Struct.pack (' H ', Be))
Newfile.write (s)
be = 0x000a000d
Newfile.write (Struct.pack (' I ', Be))
Newfile.close ()
Bfirst = False
Oldfile.close ()