我有。txt文件格式为:
  
  x1 x2 x3 y1 y2 y3 z1 z2 z3
x1 x2 x3 y1 y2 y3 z1 z2 z3
  
   例如:
  
     1.9849207e-01   1.9993099e-01   2.0150793e-01   9.6169322e-02   9.6354487e-02   1.0630896e-01   1.5000000e-02   1.6090730e-02   1.5000000e-02
   1.9993099e-01   2.0261176e-01   2.0150793e-01   9.6354487e-02   1.0536750e-01   1.0630896e-01   1.6090730e-02   1.6090730e-02   1.5000000e-02
  
   我使用了以下剪报:
  
  from itertools import *
with open('path/snip.txt', 'r') as f_input, open('path/snip_output.txt', 'w') as f_output:
    values = []
    for line in f_input:
        values.extend(line.split())
    ivalues = iter(values)
    for triple in iter(lambda: list(islice(ivalues, 3)), []):
        f_output.write(' '.join(triple) + '\n')
  
   得到:
  
  x1 x2 x3
y1 y2 y3
z1 z2 z3
x1 x2 x3
y1 y2 y3
z1 z2 z3
  
   然而,以下是我想要的,但我不知道如何在islice中处理两个步骤:
  
  x1 y1 z1
x2 y2 z2
x3 y3 z3
x1 y1 z1
x2 y2 z2
x3 y3 z3