String = n76a+q80a+l83a+i153a+l203f+r207a+s211a+s215w+f216a+e283l
我想让剧本一次看一对,意思是:
评估n76a+q80a。如果abs(76-80)<;10,则将“+”替换为“\”: 否则什么都不要改变。 然后评估q80a+l83a,然后做同样的事情。你知道吗
所需输出应为:
n76a_q80a_l83a+i153a+l203f_r207a_s211a_s215w_f216a+e283l
我试过的是
def aa_dist(x):
if abs(int(x[1:3]) - int(x[6:8])) < 10:
print re.sub(r'\+', '_', x)
with open(input_file, 'r') as alex:
oligos_list = alex.read()
aa_dist(oligos_list)
这就是目前为止我所知道的。我知道我的代码只会将所有的“+”替换为“\”,因为它只计算第一对并替换所有。我该怎么做?你知道吗
是你实现这一目标的一种方法。。。也是一个毫无价值的评论的例子
仅通过
re
模块。你知道吗通过定义一个单独的函数。你知道吗
输出:
相关问题 更多 >
编程相关推荐