#coding: UTF8 import os import os.path import XLWT import XLRD #---Get the current path---filepath=os.getcwd () #---Specify the test path---fil E01= ' F:\SVNBaloon\BalloonBlast\Assets\Scripts ' #---Start a specific identity---' Debug.Log ("' #---End a specific identification---endsign= '); ' ---Create a table---getwordexcel=xlwt. Workbook () #---Create Sheet---gettable=getwordexcel.add_sheet (' getword ', cell_overwrite_ok=true) #---Number of rows---index = 0 # ---traverse parent in the corresponding path: dirnames All folders filenames all file names---for parent,dirnames,filenames in Os.walk (FilePath): #- --Traverse All files---for filename in filenames: #---set/get the current file parent directory---totalfilepath=os.path.join (parent,fi
LENAME) #---Get files with the suffix. cs or. txt---if filename.endswith ('. cs ') or Filename.endswith ('. Lua '):
#---Get file full path---totalfile=os.path.abspath (totalfilepath) #---Open read file ' R ' for read ' W ' for write Fileinfo02=open (Totalfilepath, ' R ') #---Traverse the current file to view each row---for FILE02 in fileInfo#---Remove each line of line feed ' \ n '---file02 = file02.strip (' \ n ') #---judgment begins to mark and end Identifies whether it exists in the current row---if startsign in File02 and Endsign in FILE02: #---for cutting operations (that is, the string
Cutting)---startIndex = file02.index (startsign) if StartIndex >= 0: StartIndex + = Len (startsign) endindex = File02.index (endsign) #---finished printing
Gets the string print File02[startindex:endindex] Getword=file02[startindex:endindex] #---The string to be intercepted---newword=unicode (getword, ' utf-8 ') #---
Write the first column of the table---gettable.write (index,0,index+1) #---Write to the second column of the table--- Gettable.write (Index,1,newword) #---Number of rows from 1---index+=1 #---Determine if the table exists---I F Os.path.isfile (Filepath+ '/wordxls.xls '): Os.remove (filepath+ '/wordxls.xls ') getwordexcel.save (filepath+ '/wordxls.xls ')