small string split prob

ian iwaters at btclick.com
Sun May 12 17:13:20 EDT 2002


cheers ive just started learning
many thanks


"Max" <nospam at nospam.nospam> wrote in message
news:t1AD8.50076$zW3.665694 at news1.tin.it...
> "ian" <iwaters at btclick.com> ha scritto nel messaggio
> news:QRzD8.62305$oK4.106853 at NewsReader...
> > hi im having trouble splitting a string any help would be great!!
> > The RCPTTO contains a line read from a socket.
> > when i try to split an e-mail address into the box and domain sub parts
i
> > get a type error on index!?
> >
> > #split e-mail address
> > index = RCPTTO.find("@")
> > box = RCPTTO[0,index]
> > domain = RCPTTO[index + 1,RCPTTO.len()]
> >
> > print box
> > print domain
> >
>
> Try this one:
>
> index = RCPTTO.find("@")
> box = RCPTTO[0: index]
> domain = RCPTTO[index + 1: len(RCPTTO)]
> print box
> print domain
>
> It should work. You used , instead of : for slicing, syntax error.
> I'm not sure, but i think string have no .len() member function. I use
> len(string) to acheive the same result...
>
>





More information about the Python-list mailing list