gpt4 book ai didi

python - 值错误 : too many values to unpack , 电子邮件验证

转载 作者:行者123 更新时间:2023-11-28 18:30:50 25 4
gpt4 key购买 nike

我正在尝试通过 forms.py 对电子邮件进行验证,但它给了我一个“太多值无法解压”的错误,尽管我是 django 和 python 编程的新手。

这是我的代码:

def clean_email(self):
email = self.cleaned_data.get('email')
email_base, provider = email.split("@")
domain, extension = provider.split('.')
# if not domain == 'USC':
# raise forms.ValidationError("Please make sure you use your USC email.")
if not extension == "edu":
raise forms.ValidationError("Please use a valid .EDU email address")
return email

最佳答案

尝试这样的事情

    extension = provider[::-1].split('.')[0]
# if not domain == 'USC':
# raise forms.ValidationError("Please make sure you use your USC email.")
if not extension == "ude":
raise forms.ValidationError("Please use a valid .EDU email address")
return email

关于python - 值错误 : too many values to unpack , 电子邮件验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37617753/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com