本文介绍了如何一次替换多个整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我是python的新手并且遇到了一些问题... 我想弄清楚如何一次更改多个整数所以我可以生成这个的补充DNA链... >>> dna =""" tgaattctatgaatggactgtccccaaagaagtaggacccactaatg cagatcctgga tccctagctaagatgtattattctgctgtgaattcgatcccactaaagat""" (即acttaagatactt .....) 我学会了如何使用 >>>删除\ n字符dna =替换(dna,?\ n?,"?) 但我无法弄清楚如何编写一个脚本,将t改为a,a到t,g到c和c到g。 如果我单独更换它们 >>> dna =替换(dna,?a?,t?) 然后所有a'确实变为t'然后真正的t'无法区分。然后我想到把它们变成w,x,y,z,然后将它们改为完成,但这也需要花费太多时间。 有什么方法可以写 >>> dna =替换(dna,''a'',t)并替换(dna,''t'',a...)等等,所以它会一次改变所有4个??? 任何帮助将不胜感激:) 谢谢,LelHi, i am new to python and having some problems...I am trying to figure out how to change multiple integers at once so i can produce the complement of this DNA strand...>>>dna = """tgaattctatgaatggactgtccccaaagaagtaggacccactaatg cagatcctggatccctagctaagatgtattattctgctgtgaattcgatcccactaaagat """(ie. acttaagatactt.....)I have learnt how to remove \n character using>>> dna = replace(dna, ?\n?, "?)but i cannot figure out how to write a script that will change t to a, a to t, g to c and c to g.If i change them individually>>> dna = replace(dna, ?a?, "t?)then all the a''s do become t''s then the true t''s cannot be distinguished. I then thought of making them w,x,y,z then changing them to the complent but that also takes too much time.is there some way to write>>> dna = replace(dna, ''a'', "t") and replace(dna, ''t'', "a")...and so on so it will change all 4 at once???Any help would be greatly appreciated :)Thanks, Lel推荐答案 展开 | 选择 | Wrap | 行号 展开 | 选择 | Wrap | 行号 这篇关于如何一次替换多个整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-14 07:26