我正在尝试编写一个程序,该程序接收用户的电子邮件并打印与之关联的URL。到目前为止,我有这个:
def email_intake():
'''Takes email input from the user'''
email = input('Enter your email: ')
if email.find('@'):
return(email)
else:
print('Please enter a valid email address')
email = input('Enter your email: ')
def find_domain(email):
'''Figures out domain name associated with email provided by the user'''
domain = email.split('@')[1]
return (domain)
def url_printer(domain):
'''prints URL associated with the email provided by the user'''
print('The domain of this email address is http//:www. ', domain)
def main():
email = email_intake
domain = find_domain(email)
url_printer(domain)
main()
我知道我必须做一些字符串拼接来弄清楚我的第二个功能,但我不知道从哪里开始。我想知道是否有某种方法可以将@字符的信息收集到。如果这是有道理的。谢谢!
答案 0 :(得分:0)
URL是什么意思?如果你在谈论电子邮件的域名,通常是在'@'之后直到最后
您的find_url方法可能如下所示。
def find_url(email):
return email.split('@')[1]
P.S:假设您已经在之前的email_intake方法中验证了电子邮件的有效性。