【发布时间】:2020-06-21 23:12:00
【问题描述】:
假设我创建了一个具有静态方法的类,并希望从另一个类方法或脚本函数运行该方法。
静态方法的作用域是什么?
例如:
def Class myClass:
@staticmethod
def mystaticmethod(input):
print("blah")
def scriptfunc():
myClass.mystaticmethod()
这有效吗?
【问题讨论】:
-
你试过了吗?当你尝试它时发生了什么?
-
def Class myclass不是有效的 Python
标签: python python-3.x object scope static-methods