Python从外部模块调用类方法

Python从外部模块调用类方法,python,class,module,function-calls,Python,Class,Module,Function Calls,我需要帮助,请,我有搜索,但没有我找到的答案是我的问题工作 我需要在另一个模块的类方法中设置一个变量 (第一页) (second.py) 对cr.reg_号码('CVM107')的调用引发错误。 我尝试过car.reg_number('CVM107')、first.car.reg_number('CVM107')和许多其他组合,但我总是出错 任何帮助都将不胜感激 谢谢 请删除staticmethod中的自参数: 像这样: >>> class car(object): ...

我需要帮助,请,我有搜索,但没有我找到的答案是我的问题工作

我需要在另一个模块的类方法中设置一个变量

(第一页)

(second.py)

对cr.reg_号码('CVM107')的调用引发错误。 我尝试过car.reg_number('CVM107')、first.car.reg_number('CVM107')和许多其他组合,但我总是出错

任何帮助都将不胜感激

谢谢


请删除staticmethod中的自参数: 像这样:

>>> class car(object):
...     @staticmethod
...     def test(str):
...             print str
... 
>>> car.test('a')
a

在问题正文中发布完整的回溯。静态方法中没有
self
。如果希望传递实例,请删除
@staticmethod
from first import car

def set_reg_no():
    cr = car()
    cr.reg_number('CVM107')
>>> class car(object):
...     @staticmethod
...     def test(str):
...             print str
... 
>>> car.test('a')
a