當前位置: 首頁>>代碼示例>>Python>>正文


Python Interpreter.execute方法代碼示例

本文整理匯總了Python中Interpreter.execute方法的典型用法代碼示例。如果您正苦於以下問題:Python Interpreter.execute方法的具體用法?Python Interpreter.execute怎麽用?Python Interpreter.execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Interpreter的用法示例。


在下文中一共展示了Interpreter.execute方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test0

# 需要導入模塊: import Interpreter [as 別名]
# 或者: from Interpreter import execute [as 別名]
def test0():
    '''test concatenation'''
    s = "13 Jan 2008 00:00:00 +0000"
    scripts = '''substr(value,indexOf(value,'START','NUM',1),12)+loop(value,"substr(value,-11,18)")+substr(value,12,-12)
'''
    a = Interpreter(scripts)
    print a.execute(s)
開發者ID:CDECatapult,項目名稱:Web-Karma,代碼行數:9,代碼來源:testcase.py

示例2: test5

# 需要導入模塊: import Interpreter [as 別名]
# 或者: from Interpreter import execute [as 別名]
def test5():
    '''test loop'''
    stript = '''substr(value,indexOf(value,'NUM','\.',1),indexOf(value,'\.','22',1))+'edu'+'/'+'images'+'/'+substr(value,indexOf(value,'ANY','NUM',-1),-12)+'/'+substr(value,indexOf(value,'START','NUM',1),-12)+substr(value,-9,-8)+substr(value,5,16)
'''
    value = "1978.43.8_1a.jpg"
    e = Interpreter(stript)
    print e.execute(value)
開發者ID:CDECatapult,項目名稱:Web-Karma,代碼行數:9,代碼來源:testcase.py

示例3: test1

# 需要導入模塊: import Interpreter [as 別名]
# 或者: from Interpreter import execute [as 別名]
def test1():
    '''test loop \"\" is used to post evaluation of a expression'''
    value = "International Bussiness Machine"
    expression = '''substr(value,indexOf(value,',','UWRD',-1),indexOf(value,'LWRD','END',-1))+substr(value,indexOf(value,'LWRD','SYB',1),-6)+substr(value,indexOf(value,'START','NUM',1),indexOf(value,'LWRD','SYB',-1))'''
    loopexp = "foreach(value.split(),\"substr(value,indexOf(value,'START','UWRD'),indexOf(value,'UWRD','LWRD'))\")"
    e = Interpreter(loopexp)
    print e.execute(value)
開發者ID:CDECatapult,項目名稱:Web-Karma,代碼行數:9,代碼來源:testcase.py

示例4: test4

# 需要導入模塊: import Interpreter [as 別名]
# 或者: from Interpreter import execute [as 別名]
def test4():
    '''test switch function'''
    condi1 = "len(value) < 10"
    condi2 = "len(value) < 10"
    loopexp1 = "foreach(value.split(),\"substr(value,indexOf(value,'START','UWRD'),indexOf(value,'UWRD','LWRD'))\")"
    loopexp2 = '''foreach(foreach(value.split(),\"substr(value,indexOf(value,'START','UWRD'),indexOf(value,'UWRD','LWRD'))\"),\"value+'see'\")'''
    tuplist = "[("+condi1+","+loopexp1+"),("+condi2+","+loopexp2+")]"
    sw = "switch("+tuplist+")"
    value = "International Bussiness Machine"
    e = Interpreter(sw)
    print e.execute(value)
開發者ID:CDECatapult,項目名稱:Web-Karma,代碼行數:13,代碼來源:testcase.py

示例5: test3

# 需要導入模塊: import Interpreter [as 別名]
# 或者: from Interpreter import execute [as 別名]
def test3():
    '''test embeded loop'''
    value = "International Bussiness Machine"
    loopexp = '''foreach(foreach(value.split(),\"substr(value,indexOf(value,'START','UWRD'),indexOf(value,'UWRD','LWRD'))\"),\"value+'See'\")'''
    e = Interpreter(loopexp)
    print e.execute(value)
開發者ID:CDECatapult,項目名稱:Web-Karma,代碼行數:8,代碼來源:testcase.py


注:本文中的Interpreter.execute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。