【发布时间】:2014-04-21 00:22:11
【问题描述】:
我有一个包含这个的 .txt 文件(应该是随机名称):
My Name 4 8 7
Your Name 5 8 7
You U 5 9 7
My My 4 8 5
Y Y 8 7 9
我需要将信息放入带有名称+数字平均值的文本文件 results.txt 中。我该怎么做?
with open(r'stuff.txt') as f:
mylist = list(f)
i = 0
sk = len(mylist)
while i < sk - 4:
print(mylist[i], mylist[i+1], mylist[i+2], mylist[i+3])
i = i + 3
【问题讨论】: