使用Python解析JavaScript变量 [英] Parse JavaScript variable with Python
本文介绍了使用Python解析JavaScript变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将JavaScript变量(不是JSON格式)转换为python变量?
How can I convert a JavaScript variable (not JSON format) into a python variable?
示例JavaScript变量:
Example JavaScript variable:
{
title: "TITLE",
name: "NAME",
active: false,
info: {
key1: "value1",
dict1: {
sub_key1: "sub_value1",
sub_key2: "sub_value2",
},
dict2: {
sub_key3: "sub_value3",
sub_key4: "sub_value4",
sub_key5: "sub_value5"
},
},
list1: ["element1", "element2", "element2"],
}
推荐答案
此格式与此问题中的输入类似一>。尝试调整我在那里发布的pyparsing解析器。
This format looks just like the input in this question. Try adapting the pyparsing parser I posted there.
这篇关于使用Python解析JavaScript变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文