CONTEST - What is the (best) solution?

Claudio Grondi claudio.grondi at freenet.de
Thu Feb 3 06:39:47 EST 2005


> {Key11: Value11
> ....
> {Keyn1: Valuen1
> Keyn2: Valuen2
> ...
> Keynn:Valuenn}
>
> Each pair in a dictionary is separated by CRLF and in each dictionary
> numbers of pairs can be different.
> I need to read only the last dictionary.What is a
> best solution?
> Thanks
> Lad

What about (not tested):

stmFile = file(r"Path\FileNameOfTheFileWithDictionaries")
strFile = stmFile.read()
strLastDict = strFile[strFile.rfind('\n{"):]

?

Claudio







More information about the Python-list mailing list