【发布时间】:2014-02-26 15:34:18
【问题描述】:
使用 python 脚本,我想从用户列表中排除“@”处和之前的所有字符*。我只想查看完整的域名。 我尝试使用正则表达式、替换、子字符串、自定义函数等来实现这一点……但没有任何东西可以生成我需要的输出。 我觉得我在寻找错误的方向,我一定错过了一些简单的东西。
*用户列表:
user@domain.com
anotheruser@somedomain.org
superuser@domains.co.uk
foo@domain.com
【问题讨论】:
-
是的,你可以考虑
split()。 -
我将如何使用拆分?与子字符串一起使用?用户列表在我的脚本中生成如下:
domain = temp[1].split()[0].strip()
标签: python regex string character