kingquake21 发表于 2013-1-15 02:00:24

python写的一个串联文件的小程序

为了看小说,下了一个zip包,打开一看居然是400多个散文件,没办法,只好鼓捣了半天python把文件给串起来了,由于中间有个字符有编码问题,只好捕捉了pass掉
import ospath = "E:\\Python Workspace\\20429"newfile = open("E:\\Python Workspace\\bbsl.txt",'w')filelist = os.listdir(path)for filename in filelist:    tmpfile = open(path+'/'+filename)    print(path+'/'+filename)    try:      newfile.writelines(tmpfile.readlines())    except UnicodeDecodeError:      passnewfile.close()
页: [1]
查看完整版本: python写的一个串联文件的小程序