def complement(dna):
transtable = dna.maketrans('acgtnACGTN', 'tgcanTGCAN')
return dna.translate(transtable)
import string
dna = raw_input("Enter DNA sequence: ")
print "Reverse Complement is: ", complement(dna)
我已經檢查了dir(string)並且沒有maketrans。 有沒有辦法導入maketrans?AttributeError:'str'對象沒有屬性'maketrans'
它需要調用maketrans函數。 '從字符串導入maketrans' –
它取決於你使用什麼版本的python。 –
'transtable = string.maketrans('acgtnACGTN','tgcanTGCAN')'在python 2.7上磨損 – The6thSense