私は PyV8 を使用していundefinedます。両方を評価し、 Python の値undefinedを返すようです。nullNone
>>> evaljs("undefined")
None
>>> evaljs("null")
None
もちろん問題は、JavaScript では同じではないということです。
>>> evaljs("undefined === null")
False
False
>>> evaljs("undefined") == evaljs("null")
None
None
True
これを行う良い方法はありますか?私は実際に、JavaScript から呼び出し可能な Python 関数を書きたいと思っています。これはundefined、特定の場合とnull他の場合に返されます。
SSCCE -nessの編集:
import PyV8
context = PyV8.JSContext()
def evaljs(s):
with context:
res = context.eval(s)
print res
return res