第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

返回未定義全局名稱(chēng)的類(lèi)中的函數(shù)

返回未定義全局名稱(chēng)的類(lèi)中的函數(shù)

蕪湖不蕪 2021-12-26 14:46:34
在類(lèi)中創(chuàng)建的函數(shù)在直接調(diào)用時(shí)有效,但在同一個(gè)類(lèi)中調(diào)用時(shí)不起作用。給了我未定義的全局名稱(chēng)。我查看了其他帖子,然后檢查了我的括號(hào)、間距等,但無(wú)法看到問(wèn)題所在。在下面的代碼中,這是有效的:test1 = srtqualifier(mdlname,datatype,dataconvention,t1)print (test1.spartSABR())但這不起作用:print(test1.makequalifier()) ##NameError: global name 'spartSABR' is not defined主要代碼:import stringdatatype = "Swaption SABR Normal Volatility"dataconvention = "USD-SIFMA Municipal Swap Index-1W-SWAPTION-PHYSICAL-SEMI-BOND"mdlname = "IR_SABR"t1 = 'should-send-back-none'#datatype = raw_input("Please input Data Type: ")#dataconvention = raw_input("Please input Data Convention: ")#modelname = raw_input("Please provide model name: ")class srtqualifier:def __init__(self,mdlname,datatype, dataconvention,t1):    self.mdlname = mdlname    self.datatype = datatype    self.dataconvention = dataconvention    self.t1 = t1    self.tempholder =  self.dataconvention.split("-")    self.currency = self.tempholder[0]    def spartSABR(self):        secondpartsp = self.tempholder[1].split(" ")        secondpartsp.append(self.tempholder[2])        separator = "_"        secondpart = separator.join(secondpartsp)        secondpart = secondpart.upper()        return secondpart    def modelname(self):        mdname = {'IR_SABR':'SABR','FX_LN':'FXLN','IR_LGM':'LGM','IR_LMM':'LMM','IR_SABR_FX_LN_GC':'SABR_FX_LN_GC','IR_SABR_GC':'SABR_GC','INFLATION_SABR':'SABR_IF'}        return mdname.get(self.mdlname)
查看完整描述

1 回答

?
慕娘9325324

TA貢獻(xiàn)1783條經(jīng)驗(yàn) 獲得超4個(gè)贊

@Patrick Haugh 發(fā)現(xiàn)了您的錯(cuò)誤。有關(guān)解釋?zhuān)?qǐng)參閱Python 與 C++ 中方法和函數(shù)之間的差異。如果您是從另一種語(yǔ)言開(kāi)始使用 Python,則鏈接的答案會(huì)很有幫助。


查看完整回答
反對(duì) 回復(fù) 2021-12-26
  • 1 回答
  • 0 關(guān)注
  • 175 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)