- 论坛徽章:
- 24
|
本帖最后由 chengchow 于 2017-05-25 14:21 编辑
- [root@zbxagent01 temp]# cat a.py
- #!/usr/bin/env python
- import os
- import re
- import sys
- File="/data/temp/a"
- Column=int(os.popen("cat " + File + " | wc -l").read().strip('\r\n'))
- Column+=1
- Str=os.popen("awk 'NR!=1' " + File).read().strip('\r\n')
- for i in range(2,Column) :
- Str=os.popen("awk -v num=" + str(i) + " 'NR!=1&&NR==num' " + File).read().strip('\r\n')
- Lst=Str.split()
- LstLength=len(Lst)
- for m in Lst :
- BeginElementIndex=Lst.index(m)
- for n in range(BeginElementIndex+1,LstLength) :
- print m+"/"+Lst[n],
- print "\t",
- print "\n",
- [root@zbxagent01 temp]# ./a.py
- 1/717.2 1/10.6 1/61.2 1/9.383018 1/1.30037 717.2/10.6 717.2/61.2 717.2/9.383018 717.2/1.30037 10.6/61.2 10.6/9.383018 10.6/1.30037 61.2/9.383018 61.2/1.30037 9.383018/1.30037
- 1.3/299.8 1.3/36.7 1.3/59.9 1.3/30.50118 1.3/0.229287 299.8/36.7 299.8/59.9 299.8/30.50118 299.8/0.229287 36.7/59.9 36.7/30.50118 36.7/0.229287 59.9/30.50118 59.9/0.229287 30.50118/0.229287
- 0.5/418 0.5/10 0.5/38.3 0.5/44.2 0.5/0.061 418/10 418/38.3 418/44.2 418/0.061 10/38.3 10/44.2 10/0.061 38.3/44.2 38.3/0.061 44.2/0.061
- 0.8/580 0.8/11 0.8/42.4 0.8/46 0.8/0.481 580/11 580/42.4 580/46 580/0.481 11/42.4 11/46 11/0.481 42.4/46 42.4/0.481 46/0.481
- 0.5/395 0.5/31.84 0.5/41.5 0.5/41.9 0.5/0.131 395/31.84 395/41.5 395/41.9 395/0.131 31.84/41.5 31.84/41.9 31.84/0.131 41.5/41.9 41.5/0.131 41.9/0.131
- 0.8/441 0.8/10.6 0.8/36.5 0.8/27.7 0.8/0.164 441/10.6 441/36.5 441/27.7 441/0.164 10.6/36.5 10.6/27.7 10.6/0.164 36.5/27.7 36.5/0.164 27.7/0.164
- 1.8/357.8 1.8/44 1.8/48.2 1.8/53.01714 1.8/0.354479 357.8/44 357.8/48.2 357.8/53.01714 357.8/0.354479 44/48.2 44/53.01714 44/0.354479 48.2/53.01714 48.2/0.354479 53.01714/0.354479
复制代码
|
|