我有一个python脚本,它生成一个curl命令并将输出读入一个名为output
的变量
输出类似于:
"endpoint1: {
"[service1]endpoint": {
},
"[service1]endpoint": {
},
"[service2]endpoint": {
},
"[service2]endpoint": {
}
}
"endpoint2": {
"[service1]endpoint": {
}
},
我需要做的是解析这个输出来计算[]之间的唯一字符串,并打印出出现的字符串。比如说:
service1 3
service2 2
有什么能帮我的吗。谢谢。你知道吗
如果您的输入不是有效的JSON,请对
collections.Counter
对象和re.findall()
函数使用以下方法:输出:
相关问题 更多 >
编程相关推荐