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

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

What is this error ? ValueError invalid literal for int() with base 10: ''

问题

  1. 我在我的代码中遇到了一个错误当我运行这段代码并定义`"email"`Pycharm会显示错误
  2. ```py
  3. ValueError: 无效的字面值以基数10'mymail'
  1. email = str(input("定义您的电子邮件地址。"))
  2. key_password = int(input("定义您的密码。"))
  3. login = int(input("输入您的电子邮件地址。"))
  4. enter_password = int(input("输入您的密码。"))
  5. if email == login and key_password == enter_password:
  6. print("欢迎访问您的会员空间。")
  7. elif email == login and key_password != enter_password:
  8. print("密码错误。")
  9. elif email != login and key_password == enter_password:
  10. print("电子邮件地址错误。")
  11. else:
  12. print("电子邮件地址和密码均错误。")
  1. <details>
  2. <summary>英文:</summary>
  3. I have an error with my code. When I run this code and I define `&quot;email&quot;`, Pycharm indicates an error.
  4. ```py
  5. ValueError: invalid literal for int() with base 10: &#39;mymail&#39;
  1. email = str(input(&quot;Define your email adress. &quot;))
  2. key_password = int(input(&quot;Define your password. &quot;))
  3. login = int(input(&quot;Input your email adress. &quot;))
  4. enter_password = int(input(&quot;Input your password. &quot;))
  5. if email == login and key_password == enter_password:
  6. print(&quot;Welcome to your member space.&quot;)
  7. elif email == login and key_password != enter_password:
  8. print(&quot;Wrong password.&quot;)
  9. elif email != login and key_password == enter_password:
  10. print(&quot;Wrong email adress.&quot;)
  11. else:
  12. 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:

  1. 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?

  1. 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:

  1. 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:

确定