gpt4 book ai didi

python - 为什么这个对象不可调用?对象是项目还是列表?

转载 作者:太空宇宙 更新时间:2023-11-04 04:06:33 25 4
gpt4 key购买 nike

<分区>

我想通过函数打印列表中的项目,但它说

TypeError: 'list' object is not callable

这是我的代码:

list = ['oi', 'hi', 'hello']
def print_item(index):
print(list(index))

预期的输出是它根据索引打印项目

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com