- 论坛徽章:
- 3
|
回复 9# substr函数
但是报错:
da@da:~/try$ cat a.txt
aa 11
bb 22
cc 33
dd 44
da@da:~/try$ cat b.txt
aa 111
bb 222
cc 333
da@da:~/try$ cat c.txt
aa 1111
bb 2222
cc 3333
da@da:~/try$ cat 1.py
#!/usr/bin/python2
# coding: utf-8
import sys
KEY = sys.argv[1:]
DIC = {}
for F in KEY:
for L in open(F):
k, v = L.split()
DIC.setdefault(k, {})[F] = v
print 'name\t', '\t'.join(KEY)
for k, v in DIC.items():
print k, '\t', '\t'.join(v if i in v else '0' for i in KEY)
da@da:~/try$ python2 1.py a.txt b.txt c.txt
Traceback (most recent call last):
File "1.py", line 11, in <module>
k, v = L.split()
ValueError: need more than 0 values to unpack
|
|