shell 处理json格式数据

383 阅读1分钟

以 Python 为例获取 ip 的值:

Python 2 export PYTHONIOENCODING=utf8 curl -s 'ip.taobao.com/service/get…' |
python -c "import sys, json; print json.load(sys.stdin)['data']['ip']" Python 3 curl -s 'ip.taobao.com/service/get…' |
python3 -c "import sys, json; print(json.load(sys.stdin)['data']['ip'])"

原贴: www.tomczhen.com/2017/10/15/…