2018-06-25(生信第3题)
2018-06-25 本文已影响8人
天秤座的机器狗

题目:将DNA转成RNA序列
第一个想到的方法是用string.replace()方法,如下


这个方法适合单个替换,但是多个替换可能不太适合,比如:

这时候可以用到python中的正则表达式中的re.sub()
re.sub(pattern, repl, string, count=0, flags=0)
如下:

其中\d+是指匹配一个或多个数字
以上。
题目:将DNA转成RNA序列
第一个想到的方法是用string.replace()方法,如下
这个方法适合单个替换,但是多个替换可能不太适合,比如:
这时候可以用到python中的正则表达式中的re.sub()
re.sub(pattern, repl, string, count=0, flags=0)
如下:
其中\d+是指匹配一个或多个数字
以上。