日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
分享一個Linux下的強力Python工具

 Linux 用戶經(jīng)常需要在終端查看一些數(shù)據(jù),從文件里看或者網(wǎng)絡協(xié)議獲取數(shù)據(jù)并查看。比如,查看文件里的json數(shù)據(jù);比如,查看 etcd里存下的數(shù)據(jù)。

目前成都創(chuàng)新互聯(lián)公司已為近千家的企業(yè)提供了網(wǎng)站建設、域名、網(wǎng)站空間、網(wǎng)站運營、企業(yè)網(wǎng)站設計、讓胡路網(wǎng)站維護等服務,公司將堅持客戶導向、應用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

如果直接看 cat或者curl得到的數(shù)據(jù),如果格式亂掉了 會很痛苦的,而 Python 的json.tool可以在終端里把得到的數(shù)據(jù)格式化。

形如:cat json.file|python-m json.tool

用法及示例

 
 
 
 
  1. # 終端操作 , 
  2. vim json.file  
  3. # 寫入 如下內(nèi)容:{ "code": 0,"data": "fine","error": "success" } 

此時 cat json.file 看到的內(nèi)容是 :

 
 
 
 
  1. { "code": 0,"data": "fine","error": "success" } 

寫進去啥樣,就啥樣!

此時用上這個工具試試

 
 
 
 
  1. #終端執(zhí)行 
  2. cat json.file | python -m json.tool 
  3. # 看到的內(nèi)容會變成這樣: 
  4. "code": 0, 
  5. "data": "fine", 
  6. "error": "success"  

接下來再試試 etcd 的數(shù)據(jù)查看。

 
 
 
 
  1. # 直接 curl 一下: 
  2. curl localhost:2379/v2/keys 
  3. # 拿到這個 
  4. {"action":"get","node":{"dir":true,"nodes":[{"key":"/NSQMetaData","dir":true,"modifiedIndex":5,"createdIndex":5},{"key":"/b2c_systech_nsq","dir":true,"modifiedIndex":6726335,"createdIndex":6726335},{"key":"/hello","value":"world","modifiedIndex":4,"createdIndex":4}]}} 
  5. # 加上工具 
  6. curl localhost:2379/v2/keys |python -m json.tool 
  7. # 拿到這個 
  8. "action": "get", 
  9. "node": { 
  10. "dir": true, 
  11. "nodes": [ 
  12. "createdIndex": 5, 
  13. "dir": true, 
  14. "key": "/NSQMetaData", 
  15.  
  16. "modifiedIndex": 5 
  17. }, 
  18. "createdIndex": 6726335, 
  19. "dir": true, 
  20. "key": "/b2c_systech_nsq", 
  21. "modifiedIndex": 6726335 
  22. }, 
  23. "createdIndex": 4, 
  24. "key": "/hello", 
  25. "modifiedIndex": 4, 
  26. "value": "world" 

可見,這個小工具,在終端環(huán)境下的幫助還是很大的,值得一學。


網(wǎng)頁題目:分享一個Linux下的強力Python工具
轉(zhuǎn)載來于:http://www.5511xx.com/article/cccspdj.html