所以我試圖改變一個隨機變量爲一個函數的字符串,任何想法,爲什麼這是行不通的?如何在python中將變量更改爲字符串?
def letter(x):
if x == 1:
x = "A"
elif x == 2:
x = "C"
elif x == 3:
x = "G"
elif x == 4:
x = "T"
else:
print "Error"
randint18= random.randrange(1,5)
letter(randint18)
print randint18 `
往回走你的Python控制檯慢,深呼吸,然後閱讀[這篇文章](http://robertheaton.com/2014/02/09/pythons-pass-by-object-reference-as-explained-by-philip-k-dick/)right現在。 –