锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产精品综合小说图片区,久久99亚洲网美利坚合众国,欧美日韩福利http://www.aygfsteel.com/mainamaiya/category/29014.htmlSimple is best.zh-cnThu, 17 Jan 2008 11:05:45 GMTThu, 17 Jan 2008 11:05:45 GMT60A Stupid Way to Reverse Chinese Filehttp://www.aygfsteel.com/mainamaiya/archive/2008/01/17/176018.htmlMaiMaiThu, 17 Jan 2008 09:37:00 GMThttp://www.aygfsteel.com/mainamaiya/archive/2008/01/17/176018.htmlhttp://www.aygfsteel.com/mainamaiya/comments/176018.htmlhttp://www.aygfsteel.com/mainamaiya/archive/2008/01/17/176018.html#Feedback0http://www.aygfsteel.com/mainamaiya/comments/commentRss/176018.htmlhttp://www.aygfsteel.com/mainamaiya/services/trackbacks/176018.html

#	ReversFile.py [infile] [outfile]
#
#	A stupid way to reverse a chinese text file. just for fun.
#	If you wanna get the same result, maybe you should only slipt  
#	input text file to character list and '.reverse' it,
#         more simpler and clearer than this.
#Note::	This code have some problem about chinese quotation marks,
#	cause it's has differnet between left and right. 
#	So when it been reversed, the result may "unreadable":) Easy fixed but I ignored.
#	Also about 'Enter' key, ignored too.
#
#		writen by Mai 01/17/2008
# 

# -*- coding: cp936 -*-
import sys

class revFileFont:
    readLines=[]
    inFile=""
    outFileName=""
    outList=[]
    def __init__(self,fileName,outFile):
        self.inFile = open(fileName,"r")
        self.outFileName = open(outFile,"w")


    def __readToList(self):
        self.inFile.seek(0)
        self.inFile
        for line in self.inFile:
            self.readLines.append(line.decode("gbk"))
        rangeList = len(self.readLines)
        self.readLines.reverse()
        for i in range(rangeList):
            rString = self.readLines[i]
            xi=len(rString)
            for xii in range(xi):
                if rString[xi-xii-1]!=u'\n':
                   self.outList.append(rString[xi-xii-1])
            self.outList.append(u'\n')        

    def DoIt(self):
	"""Reverse file and write it out."""
        self.__readToList()
        for i in self.outList:
            self.outFileName.write(i.encode("gbk"))
        self.inFile.close()
        self.outFileName.close()

if __name__ == "__main__":
    argc = len(sys.argv)
    if argc <> 3:
	print 'Useage:',sys.argv[0],' [inFile]',' [outFile]'
	sys.exit(1)
    test = revFileFont(sys.argv[1],sys.argv[2])
    test.DoIt()
   #print test.outList


Mai 2008-01-17 17:37 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 阜康市| 遂平县| 老河口市| 南投县| 桐柏县| 安义县| 建始县| 普陀区| 南川市| 柞水县| 江孜县| 临漳县| 肥西县| 江山市| 贵州省| 台江县| 沙洋县| 新安县| 昌图县| 营口市| 灵武市| 陆良县| 天长市| 姚安县| 金湖县| 雅安市| 金溪县| 千阳县| 乌拉特中旗| 正镶白旗| 山阳县| 九江县| 乐山市| 喀喇沁旗| 兴仁县| 阆中市| 山阳县| 丁青县| 特克斯县| 体育| 江川县|