相关疑难解决方法(0)

TypeError:尝试访问列表时,'list'对象不可调用

我正在尝试运行此代码,我有一个列表列表.我需要添加到内部列表,但我得到错误

TypeError: 'list' object is not callable.
Run Code Online (Sandbox Code Playgroud)

任何人都可以告诉我这里我做错了什么.

def createlists():
    global maxchar
    global minchar
    global worddict
    global wordlists

    for i in range(minchar, maxchar + 1):
        wordlists.insert(i, list())
    #add data to list now
    for words in worddict.keys():
        print words
        print  wordlists(len(words)) # <--- Error here.
        (wordlists(len(words))).append(words)  # <-- Error here too
        print "adding word " + words + " at " + str(wordlists(len(words)))
    print wordlists(5)
Run Code Online (Sandbox Code Playgroud)

python callable

52
推荐指数
4
解决办法
41万
查看次数

参考 - 这个正则表达式意味着什么?

这是什么?

这是常见问答的集合.这也是社区Wiki,因此每个人都被邀请参与维护.

为什么是这样?

患的是给我泽码型的问题和答案不佳,没有解释.此参考旨在提供质量问答的链接.

范围是什么?

此引用适用于以下语言:,,,,,,.

这可能过于宽泛,但这些语言共享相同的语法.对于特定功能,它背后的语言标签,例如:

  • 什么是正则表达式平衡组?

regex

52
推荐指数
1
解决办法
11万
查看次数

TypeError:'function'对象不可订阅 - Python

我试图用这段代码解决一项任务:

bank_holiday= [1, 0, 1, 1, 2, 0, 0, 1, 0, 0, 0, 2] #gives the list of bank holidays in each month

def bank_holiday(month):
   month -= 1#Takes away the numbers from the months, as months start at 1 (January) not at 0. There is no 0 month.
   print(bank_holiday[month])

bank_holiday(int(input("Which month would you like to check out: ")))
Run Code Online (Sandbox Code Playgroud)

但是当我运行它时,我收到错误:

TypeError: 'function' object is not subscriptable
Run Code Online (Sandbox Code Playgroud)

我不明白这是从哪里来的......

python

8
推荐指数
1
解决办法
6万
查看次数

在python中,何时使用方括号或圆括号?

我是一名刚开始学习 Python(第 3 版)的非程序员,并且对我的代码中何时需要方括号与圆括号有点困惑。

是否有一般的经验法则?

python python-3.x

5
推荐指数
3
解决办法
2万
查看次数

在 python 中的 bytes() 调用中用方括号括起一个整数是什么意思?

假设你写bytes(10),根据我的理解,这将创建一个 10 个字节的字节数组;但是,如果您改为写入bytes([10]),则会得到二进制值 10。

方括号对数字的数据类型有什么影响?作为操作员,我找不到有关它们的任何信息。

python types

2
推荐指数
1
解决办法
42
查看次数

标签 统计

python ×4

callable ×1

python-3.x ×1

regex ×1

types ×1