Re: Find the ID, but how to select/copy the whole string by ID?

2007-09-19 Thread Francesco Guerrieri
On 9/19/07, Carsten Haese <[EMAIL PROTECTED]> wrote: > , then looking for id 12 is going to match on the wrong ID. Besides, > that code only tells you where something that looks like the ID you're > looking for is in the file. There is no guarantee that the match > actually occurs inside an ID att

Re: Find the ID, but how to select/copy the whole string by ID?

2007-09-19 Thread Carsten Haese
On Wed, 2007-09-19 at 16:41 +0200, Francesco Guerrieri wrote: > On 9/19/07, Leon <[EMAIL PROTECTED]> wrote: > > stringID = str(raw_input('Enter the string ID : ')) > > file = open('strings.txt') > > sourcefile = file.read() > > file.close() > > sourcefile.find (stringID) > > > > but how can I selec

Re: Find the ID, but how to select/copy the whole string by ID?

2007-09-19 Thread Zentrader
sourcefile.find(stringID) returns the start location. You can use print to see this. You can then slice from start+len(stringID) and print it out. That should give you enough info to figure out how to find and extract to the end of the string tag as well. There are other ways to do this, but str

Re: Find the ID, but how to select/copy the whole string by ID?

2007-09-19 Thread Francesco Guerrieri
On 9/19/07, Leon <[EMAIL PROTECTED]> wrote: > stringID = str(raw_input('Enter the string ID : ')) > file = open('strings.txt') > sourcefile = file.read() > file.close() > sourcefile.find (stringID) > > but how can I select and copy the specific string from to > with id I input? If the file you a

Find the ID, but how to select/copy the whole string by ID?

2007-09-19 Thread Leon
Hi everybody, I am a beginer for Python, hope can get help from you guys. What I want to do is : Input an ID -> find the ID in the file -> copy the whole string y stringID = str(raw_input('Enter the string ID : ')) file = open('strings.txt') sourcefile = file.read() file.close() sourcefile.