search for a string?
Stephen Hansen
stephen at cerebralmaelstrom.com
Thu Jun 1 18:10:51 EDT 2000
Depends on how you have the document opened/loaded...
If its all in one string you could just use:
string.find(Document,Substring)
[Document.find(Substring) in py1.6]
If its in a list, a la readlines? Hm.
string.find(string.join(Document),Substring)
["".join(Document).find(Substring) in py1.6]
Etcetc..you could cycle through a file or do whatever you wanted to..
As for inserting the contents of another file, well, something like:
OldString = File.read() + OldString
I perfer, though: OldString = "%s %s" % (File.read(),OldString)
--S
Shengquan Liang <gt2558b at prism.gatech.edu> wrote in message
news:8h6211$ark$1 at news-int.gatech.edu...
>
> how do i search for a string in a document
>
> and inseart content of another file before
> that string?
>
>
>
More information about the Python-list
mailing list