python - builtin_function_or_method 不支持的操作数类型
问题描述
我的代码有问题。我需要创建一个代码,说明输入的数字是偶数还是奇数。代码是
print ("enter a number")
a = input
if a% 2 == 0:
print ("even")
else:
print ("odd")
错误是:
TypeError: unsupported operand type (s) for%: 'builtin_function_or_method' and 'int'
我应该改变什么?
谢谢你。
解决方案
您需要先将输入转换为整数。
推荐阅读
- javascript - renderToString 导致 Uncaught ReferenceError: require is not defined
- r - Shiny to Markdown PDF 在第二次和后续运行中失败
- javascript - 如何仅使注销按钮出现而没有来自单独组件的CSS
- r - R数据框,用来自同一变量的值更改变量中的值
- ruby-on-rails - Heroku staging 应用程序是否与评论应用程序共享数据库?
- javascript - Javascript D3位置工具提示到图表
- android - IllegalStateException:使用 BottomNavigation 时尚未附加 Fragment
- sql-server - 获取最接近 AVG TSQL 函数的值
- qt - 如果它是使用 QRegExp 的逗号,如何删除第一个字符?
- android - 如何有选择地使用 Google Play 服务包?