-1
我是Python的新手,迄今爲止我只使用過VBA。我想知道是否有辦法將類對象的實例作爲參數/參數傳遞給函數。我想有像我所抄錄如下在Python中將對象作爲參數傳遞給函數
#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!您可以先[參觀](http://stackoverflow.com/tour)並學習[如何提出一個好問題](http://stackoverflow.com/help/how-to-ask)並創建一個[最小,完整和可驗證](http://stackoverflow.com/help/mcve)示例。這使我們更容易幫助你。 –