相关疑难解决方法(0)

如何编写静态python getitem方法?

为了使这项工作,我需要改变什么?

class A:
    @staticmethod
    def __getitem__(val):
        return "It works"

print A[0]
Run Code Online (Sandbox Code Playgroud)

请注意,我__getitem__在类型上调用方法A.

python static magic-methods operator-keyword

12
推荐指数
2
解决办法
4238
查看次数

标签 统计

magic-methods ×1

operator-keyword ×1

python ×1

static ×1