small string split prob

Max nospam at nospam.nospam
Sun May 12 16:13:13 EDT 2002


"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