直接定义一个类对象

时间:2019-02-27 12:11:40

标签: python

我定义了以下类别:     从scipy.interpolate导入interp1d

class nmat:
   #def __init__(self):

   def staticmat(self,cn):
       self.cn_static = cn

   def staticmatX2(self,cn):
       self.cn_static = 2*cn

现在,我想创建此类的对象。我执行以下操作:

matw = nmat()
matw.staticmat(2.1)
matw.cn_static

有没有办法像这样输入它?

matd = nmat.staticmat(2.1)

不是先初始化?

0 个答案:

没有答案