Generic access to DBM-style databases,dbm-styledatabases,import filei
Generic access to DBM-style databases,dbm-styledatabases,import filei
import fileinput, os, anydbmwordPos = {}sep = os.pathsepfor line in fileinput.input(): pos = '%s%s%s'%(fileinput.filename(), sep, fileinput.filelineno()) for word in line.split(): wordPos.setdefault(word,[]).append(pos)dbmOut = anydbm.open('indexfile','n')sep2 = sep * 2for word in wordPos: dbmOut[word] = sep2.join(wordPos[word])dbmOut.close()
- String formatting: Integer, Decimal and Hexadeciaml,,i
- range with step,rangestep,from math im
- Zip function demo: returns a list of tuples,returnstu
- Print lines/words/chars stats of files by extension,ch
- ord function demo,ordfunction,print ord('s
- tuples: swaps values,tuplesswapsvalues,nudge = 1win
热门文章:
相关内容
- String formatting: Integer, Decimal and Hexadeciaml,,integerValue
- range with step,rangestep,from math im
- Zip function demo: returns a list of tuples,returnstuples,D1 = {}D
- Print lines/words/chars stats of files by extension,charsstats,'''P
- ord function demo,ordfunction,print ord('s
- tuples: swaps values,tuplesswapsvalues,nudge = 1win
- Extracting Nodes Selected by XPath Specifiers,extractingxpath,impor
- Define and use variables in Python,variablespython,print 'Power
- Find a program in PATH system Variable,pathvariable,'''PYTHON SO
- For loop combined with in function,loopcombined,from math im
评论关闭