我在读一个文件,它看起来像:Protein in water
5826
300LEU N 2945 7.972 16.153 13.055 -0.0183 0.4861 -0.4376
300LEU H 2946 8.006 16.194 13.139 1.5894 1.3176 -1.4422
300LEU CA 2947 8.017 16.020 13.016 0.1247 0.7136 -0.1096
300LEU CB 2948 8.157 15.990 13.077 -0.0499 0.0576 0.0414
300LEU CG 2949 8.273 16.081 13.032 -0.3927 -0.5342 0.1311
300LEU CD1 2950 8.271 16.143 12.895 0.2232 0.1271 0.2677
300LEU CD2 2951 8.281 16.197 13.136 0.0409 -0.0097 0.0710
300LEU C 2952 7.917 15.908 13.047 0.5031 0.0949 0.0620
300LEU O 2953 7.955 15.799 13.093 -0.2261 -0.5800 0.0226
我得把前两行去掉,分别读不同的专栏。
我试过这个:with open('file.txt') as fa:
for line_aa in fa.readlines()[3:11]:
line_aa = line_aa.strip()
print line_aa
col1,col2,col3,col4,col5,col6,col7,col8,col9 = line_aa.split(' ',9)
但我得到了以下错误:300LEU H 2946 8.110 15.548 13.027 -0.0632 0.8718 -0.8443
Traceback (most recent call last):
File "rmsd_cg_vs_aa.py", line 50, in
col1,col2,col3,col4,col5,col6,col7,col8,col9 = line_aa.split(' ',9)
ValueError: need more than 1 value to unpack
我错过了什么?