我想将 javascript 翻译成 python。
但是当我得到 bgAudio 时,它等于 [object Object]。
谁能告诉我如何获得“bgAudio”的值。(更好的json类型,例如{“url”:“a/b/c/d/e.mp3”,“name”:“aaa.mp3” })?
或者如何获取《class '_PyV8.JSObject'》的值?
谢谢。
import PyV8
str_scene2 = """
var scene = {id:123321,bgAudio:{"url":"a/b/c/d/e.mp3","name":"aaa.mp3"}};
"""
s1 = str_scene2.decode('utf-8')
with PyV8.JSContext() as env1:
env1.eval(s1)
vars = env1.locals
var_scene1 = vars.scene
print var_scene1.id
print var_scene1.bgAudio # it shows [object Object]
print type(var_scene1.bgAudio) # it shows <class '_PyV8.JSObject'>