On Feb 15, 3:34 pm, galileo228 <mattbar...@gmail.com> wrote: > > I'm trying to write python code that will open a textfile and find the > email addresses inside it. I then want the code to take just the > characters to the left of the "@" symbol, and place them in a list. > (So if galileo...@gmail.com was in the file, 'galileo228' would be > added to the list.) > > Any suggestions would be much appeciated! >
You may want to use regexes for this. For every match, split on '@' and take the first bit. Note that the actual specification for email addresses is far more than a single regex can handle. However, for almost every single case out there nowadays, a regex will get what you need. -- http://mail.python.org/mailman/listinfo/python-list