英文:
What is this error ? ValueError invalid literal for int() with base 10: ''
问题
我在我的代码中遇到了一个错误。当我运行这段代码并定义`"email"`时,Pycharm会显示错误。
```py
ValueError: 无效的字面值以基数10:'mymail'
email = str(input("定义您的电子邮件地址。"))
key_password = int(input("定义您的密码。"))
login = int(input("输入您的电子邮件地址。"))
enter_password = int(input("输入您的密码。"))
if email == login and key_password == enter_password:
print("欢迎访问您的会员空间。")
elif email == login and key_password != enter_password:
print("密码错误。")
elif email != login and key_password == enter_password:
print("电子邮件地址错误。")
else:
print("电子邮件地址和密码均错误。")
<details>
<summary>英文:</summary>
I have an error with my code. When I run this code and I define `"email"`, Pycharm indicates an error.
```py
ValueError: invalid literal for int() with base 10: 'mymail'
email = str(input("Define your email adress. "))
key_password = int(input("Define your password. "))
login = int(input("Input your email adress. "))
enter_password = int(input("Input your password. "))
if email == login and key_password == enter_password:
print("Welcome to your member space.")
elif email == login and key_password != enter_password:
print("Wrong password.")
elif email != login and key_password == enter_password:
print("Wrong email adress.")
else:
print("Wrong email adress and password.")
答案1
得分: 1
I'm guessing your error comes from here:
login = int(input("Input your email address. "))
You're trying to interpret your input as an int
when it will probably be an email address. Maybe you meant to do the following?
login = str(input("Input your email address. "))
As the comments indicated the str()
here is redundant since input()
returns a string. So you could just do:
login = input("Input your email address. ")
英文:
I'm guessing your error comes from here:
login = int(input("Input your email adress. "))
You're trying to interpret your input as an int
when it will probably be an email address. Maybe you meant to do the following?
login = str(input("Input your email adress. "))
As the comments indicated the str()
here is redundant since input()
returns a string. So you could just do:
login = input("Input your email adress. ")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论