Python快捷調用JS函數代碼

Python · 11 天前 · 9 人浏览
import execjs
def runJS(filePath, funcName, *args):
    with open(filePath, 'r', encoding='utf-8') as f:
        jscode = f.read()

    ctx = execjs.compile(jscode)
    res = ctx.call(funcName, *args)
    return res

return_value = runJS('test.js', '函數名', "函數參數1")
本站立足于美利堅合衆國,請讀者自覺遵守當地法律!如有違規,本站不承擔任何法律責任! This site is based in the United States of America, readers are requested to abide by local laws! If there are any violations, this site does not bear any legal responsibility! Theme Jasmine by Kent Liao