-3
私は、Pythonでindex()を使用するためにインポートする必要はありますか?
import clr
import System
import ServiceDesk
import BaseModel
class Model(BaseModel.Model):
def ExecuteCustomAction(self,args,env):
resault = self.account.ExecuteService('service',args,env)
res = {}
if resault.Count>0:
for customaction in resault.Rows:
CustomActions = customaction['CustomActions']
if CustomActions !="":
Lable = self.find_between(CustomActions, "Lable", "d")
CallBack = self.find_between(CustomActions, "CallBack", ";")
Action = self.find_between(CustomActions, "Action", "f")
res['Lable'] = Lable
res['CallBack'] = CallBack
res['Action'] = Action
return res
def find_between(text, first, last ,self):
try:
start = text.index(first) + len(first)
end = text.index(last, start)
return text[start:end]
except ValueError:
return ""
を、以下の目的球を呼んでいるが、私はこれを実行すると、それは私がインポートする必要がありますかどう
オブジェクトが属性 'インデックス'
を持っていないと言いますか?
は、どのように関数を呼び出していますか?そのコードも追加してください。 – JRodDynamite
「テキスト」は何もありませんが、メソッド 'index'はありません。それはおそらくあなたが考えるものではありません。 – RemcoGerlich
何もインポートする必要はありません。メソッド 'index'を持つオブジェクトを渡す必要があります。 – deceze