python - 学习使用 Minecraft (Python) 编程中的代码不起作用
问题描述
我对编程完全陌生。我有这本书 Learn To Program With Minecraft: Transform Your World With The Power of Python。这本书没有真正的客户支持。
我正在学习逻辑运算符顺序。本书以以下代码为例:
wolves = input("Enter the number of wolves: ")
enoughWolves = wolves > 10 and wolves < 20
print("Enough wolves: " + str(enoughWolves))
我完全按照书上说的编写代码,但出现以下错误:
Traceback (most recent call last):
File "/Users/myName/Documents/wolves.py", line 3, in <module>
enoughWolves = wolves < 20
TypeError: '<' not supported between instances of 'str' and 'int'
我不明白这个错误信息是什么意思,也不明白为什么这本书的代码不起作用。谁能帮我?
解决方案
推荐阅读
- swift - 将 UIImageView 添加到 UIScrollView 以编程方式缩放图像
- neo4j - Neo4j count() 返回不正确的值
- jquery - 如何在这个特定的 AJAX 调用中获得成功消息?
- c - 关于运算符的指针和值
- ssas - SSAS 根据时间层次和货币显示 1 个值
- javascript - 我正在尝试使用 fetchApi 来获取数据,但我收到了这个错误
- swift - 如何将 18 位时间戳转换为小时分钟和秒?
- mysql - 根据先前计算的字段计算 MySQL Select 字段
- algorithm - 算法,伪代码
- sql-server - 寻找一种方法来衡量跟踪和错误查询替代方案