简体   繁体   English

知道为什么我的变量不会打印吗?

[英]Any idea why my variables won't print?

I know why these types of errors generally occur, but in my situation, I can't figure out why.我知道为什么通常会发生这些类型的错误,但在我的情况下,我无法弄清楚原因。

Here's what I'm trying to do: First of all, the type of file I'm working with is a spreadsheet that contains integers and strings, or combinations of both in a given cell.这是我想要做的:首先,我正在处理的文件类型是一个电子表格,其中包含整数和字符串,或在给定单元格中两者的组合。

Now, I have previously written a program that will allow me to append and make a list of all values from a given column on this spreadsheet, and all the values look something like this "c.2232_2234A>G" or "c.23C>T" (these are the types of values that the variables 'mutation' and 'mutation_list' contain. So, for each value in my list, I want to cross-reference it with all other values in my list and find possible matches, and then if they match, then I want to append certain info from a different column of the spreadsheet and print it, and so on.现在,我之前编写了一个程序,允许我附加并列出该电子表格上给定列中的所有值,并且所有值看起来都类似于“c.2232_2234A>G”或“c.23C> T”(这些是变量 'mutation' 和 'mutation_list' 包含的值的类型。因此,对于列表中的每个值,我想将它与列表中的所有其他值进行交叉引用并找到可能的匹配项,并且然后,如果它们匹配,那么我想从电子表格的不同列附加某些信息并打印它,依此类推。

Edit: I just changed it so that I am comparing the same list against itself.编辑:我只是改变了它,以便我将同一个列表与其自身进行比较。 So in this given list, for a particular mutation, I want it to cross-reference it with all other mutations in the list and append the family number and other variables (listed below) for those matches.所以在这个给定的列表中,对于特定的突变,我希望它与列表中的所有其他突变交叉引用它,并为这些匹配附加家族编号和其他变量(如下所列)。 Although now I don't get the index error, I don't get an output in terms of the variables that I listed.虽然现在我没有得到索引错误,但我没有得到我列出的变量的输出。 Any ideas?有任何想法吗?

Here's what I have so far:这是我到目前为止所拥有的:

for y in range(1, len(mutation)):
      for z in range(1,len(mutation):
            if mutation[y] == mutation[z]:
                  print "Family Number", family_num[z], "\t", "Result", result[z], "\t", "Mutation", mutation[y], "\t", "Site", site[z]

Thanks!谢谢!

In the print statement, concatenate the list, variables, whatever, to string.在打印语句中,将列表、变量等连接成字符串。 Try that?试试那个?

for y in range(1, len(mutation)):
      for z in range(1,len(mutation):
            if mutation[y] == mutation[z]:
                  print("Family Number", str(family_num[z]), "\t", "Result", str(result[z]), "\t", "Mutation", str(mutation[y]), "\t", "Site", str(site[z]))

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

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