简体   繁体   English

需要帮助循环打印多行

[英]Need help printing multiple rows in loop

I have a print statement, 我有一份打印声明,

print '0.860\t', model[i+26][16],'\t', 0.1*(float(model[i+26][16])),'\t','35\t I (assume 10% error)'

Briefly, my data file is multiple rows, this specific print command prints a row from a specific value (there are multiple values, each with it's own print command). 简而言之,我的数据文件是多行,此特定的打印命令从特定值打印一行(有多个值,每个值都有自己的打印命令)。 Now, my data has multiple rows for specific values so the print command (here) just ends up printing the first row it comes across. 现在,我的数据具有多个用于特定值的行,因此print命令(此处)只是结束了所遇到的第一行的打印。 Obviously, I need every row printed that it may come across. 显然,我需要打印出可能遇到的每一行。

I'm not that good with python so I have only a limited experience with while and range() commands. 我对python不太满意,所以我对while和range()命令只有有限的经验。 I'm finding this tricky because it already has the iterative variable 'i' inside of it, so I don't know how to call the whole row. 我发现这很棘手,因为它里面已经有迭代变量“ i”,所以我不知道如何调用整行。 Thanks. 谢谢。

>>> a=[[1,2,3],[4,5,6],[7,8,9]]
>>> for i in a :
...         print i
... 
 [1, 2, 3]
 [4, 5, 6]
 [7, 8, 9]

To keep a track of index we can use: 为了跟踪索引,我们可以使用:

for count,i in enumerate(a) :
    ...         print a[count]
    ... 


[1, 2, 3]
[4, 5, 6]
[7, 8, 9]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM