【发布时间】:2013-10-10 02:57:04
【问题描述】:
这个函数打印多个值,它们是字符串 z 的索引,但是我想存储这些值,使用 return 将终止函数,只留下几个值的第一个值。
def find(a):
index=a
while index<len(z)-1:
if z[index]=="T":
for index in range (index+20,index+30):
if z[index]=="A" and z[index+1]=="G" and z[index+2]=="T":
a=index
print a
index=index+1
【问题讨论】:
-
也许使用
yield而不是print -
@user2842500:您可能想阅读的内容:python.org/dev/peps/pep-0008