这个错误是什么?数值错误,使用基数10时int()无效文字:”

huangapple go评论75阅读模式
英文:

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 `&quot;email&quot;`, Pycharm indicates an error.

```py
ValueError: invalid literal for int() with base 10: &#39;mymail&#39;
email = str(input(&quot;Define your email adress. &quot;))
key_password = int(input(&quot;Define your password. &quot;))

login = int(input(&quot;Input your email adress. &quot;))
enter_password = int(input(&quot;Input your password. &quot;))

if email == login and  key_password == enter_password:
    print(&quot;Welcome to your member space.&quot;)
elif email == login and  key_password != enter_password:
    print(&quot;Wrong password.&quot;)
elif email != login and  key_password == enter_password:
    print(&quot;Wrong email adress.&quot;)
else:
    print(&quot;Wrong email adress and password.&quot;)

答案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(&quot;Input your email adress. &quot;))

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(&quot;Input your email adress. &quot;))

As the comments indicated the str() here is redundant since input() returns a string. So you could just do:

login = input(&quot;Input your email adress. &quot;)

huangapple
  • 本文由 发表于 2020年1月4日 01:31:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/59582863.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定