我想要的DNA代碼轉換成使用Python代碼RNA ...使用DNA到RNA str.translate()
我寫這篇文章:
print('Digite a sequência DNA a ser transcrita para RNA:')
my_str = raw_input()
print(my_str.replace('T', 'U'))
和它的作品,但。現在我需要一個轉換至U,噸至一個,摹到C和C到G ...我看着我怎麼能做到這一點,而且這樣做:
print('Digite a sequência DNA a ser transcrita para RNA:')
my_str = raw_input()
RNA_compliment = {
ord('A'): 'U', ord('T'): 'A',
ord('G'): 'C', ord('C'): 'G'}
my_str.translate(RNA_compliment)
但我得到這個錯誤:
Traceback (most recent call last):
File "rna2.py", line 15, in <module>
my_str.translate(RNA_compliment)
TypeError: expected a character buffer object
我做錯了什麼?
相關:http://stackoverflow.com/questions/21038891/what-does-table-the-string-translate-function-mean – NightShadeQueen