small string split prob
Bengt Richter
bokr at oz.net
Sun May 12 17:35:51 EDT 2002
On Sun, 12 May 2002 21:53:00 +0100, "ian" <iwaters at btclick.com> wrote:
>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
>
What am I missing? "... _split_ an e-mail address..."
is so suggestive of .split ;-)
>>> RCPTTO = 'boxname at some.domain.com'
>>> box,domain = RCPTTO.split('@',1)
>>> print box
boxname
>>> print domain
some.domain.com
Regards,
Bengt Richter
More information about the Python-list
mailing list