我有以下字符串:
"[['Categories', [['180972'], ['180800'], ['16228'], ['32733'], ['32789'], ['32833'], ['325137'], ['32839'], ['25329'], ['42605'], ['428240849'], ['5101'], ['568'], ['570716'], ['57116'], ['57080545404'], ['57083134076']]], ['Tags', ['Stock', 'Color', 'Fam', 'Dress','Maxi']], ['Type', ['Luxary']], ['Vendor', ['AAA']]]"
我想把它解析为dict/json。 最好的方法是什么?你知道吗
尝试将其转换为dict:
输出为:
这个怎么样
可以使用} 。你知道吗
ast.literal_eval
计算字符串并返回Python对象(如果语法正确)。Using this is safer than using ^{如果您还想摆脱内部列表,请使用the other answer,而不是只调用对象上的
dict
。你知道吗相关问题 更多 >
编程相关推荐