001、方法1
root@PC1:/home/test# ls test.py root@PC1:/home/test# cat test.py ## 测试程序 #!/usr/bin/python str1 = "GAGCCTACTAACGGGAT" ## 两天等长序列 str2 = "CATCGTAATGACGGCCT" count = 0; for i in range(len(str1)): if str1[i] != str2[i]: count += 1 print(count) root@PC1:/home/test# python test.py ## 执行程序 7
002、方法2
root@PC1:/home/test# ls test.py root@PC1:/home/test# cat test.py ## 测试程序 #!/usr/bin/python str1 = "GAGCCTACTAACGGGAT" str2 = "CATCGTAATGACGGCCT" count = sum([i != j for i,j in zip(str1,str2)]) print(count) root@PC1:/home/test# python test.py ## 执行程序 7
参考:https://mp.weixin.qq.com/s?__biz=MzIxMjQxMDYxNA==&mid=2247484182&idx=1&sn=b9827db4bd9c4eebcd48d546f50b4226&chksm=9747ca8fa0304399e708fab685019647a8ed6649bcbb320b95b776ed8cd66ee967fdac9a5e6c&scene=178&cur_album_id=1635727573621997580#rd
标签:py,python,碱基,个数,PC1,test,home,root From: https://www.cnblogs.com/liujiaxin2018/p/16598924.html