Python 'builtin_function_or_method' 对象没有属性 '__getitem__'

标签 python

我试图测试一些东西,以便我可以进行 python 文本冒险,但它不起作用。这是代码:

calories = [3]

fooland= ("fooland")
area=fooland
joint= ("joint")

while area=="fooland":
talk=raw_input("Where to go?")

if talk==joint:
    area=joint

else:
    print "You cant do that!"


while area=="joint":
order=raw_input("What to order?")

if order=="fries":
    print "You eat like a BAWS"
    calories.append[2]

else:
    print "You cant eat that, but here is some grease!"
    calories.append[6]

 if [calories < 10]:
print "YOU ARE FAT"

但是我得到这个错误:

'builtin_function_or_method' object has no attribute '__getitem__'

我做错了什么,我该如何解决?

最佳答案

要调用一个方法(如 append),您将参数包装在 () 而不是 [] 中。

关于Python 'builtin_function_or_method' 对象没有属性 '__getitem__',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22418242/

相关文章:

python - 压缩一维 numpy 数组到二维汉明距离矩阵

python - 如何查看 Django 登录生产环境

python - 按列标题排列 DataFrame 列

Python 2.7/App Engine - TypeError : is_valid() takes exactly 2 arguments (3 given)

Python字典内存使用

python - 如何按名称查找特定子文件夹并重命名?

python - 在 Python 3 中,更改列表中值的最有效方法是什么?

python - 我该如何修复这个 mitmproxys SyntaxError?

python - 从数据集中提取文本

python - 使用python调用锁屏