【发布时间】:2017-06-04 18:16:04
【问题描述】:
我是 Python 的新手,到目前为止我只使用过 VBA。我想知道是否有办法将类对象的实例作为参数/参数传递给函数。我想要一些类似我在下面复制的东西
#ClassOne.py
class Spnt(object):
def __init__ (self, wl, val):
self.wl = wl
self.val = val
#AnotherFile.py
import ClassOne
def func(obj1, obj2)
#where obj1 and obj2 are instances of the object Spnt()
# .....code which does some math
# returns obj3 which is another instance of the Class object Spnt()
感谢您的阅读
【问题讨论】:
-
您自己尝试过吗?
-
欢迎来到 Stack Overflow!您可以先take the tour 学习How to Ask a good question 并创建Minimal, Complete, and Verifiable 示例。这让我们更容易为您提供帮助。
标签: python class object parameters arguments