nodes
という名前のクラスのリストがNodeクラスのインスタンスで構成されています。文字列をPythonのコマンド文の末尾に連結する方法
class Node:
def __init__(self, bucketNumber ,colorONE, colorTWO,
colorTHREE, colorFOUR, colorFIVE):
self.bucket = bucketNumber # index
self.color1 = colorONE # quantity
self.color2 = colorTWO # quantity
self.color3 = colorTHREE # quantity
self.color4 = colorFOUR # quantity
self.color5 = colorFIVE # quantity
私は、彼らが望むものを、色数をユーザーに尋ねます。私はそのintをとり、単語 "color"と数字を連結したいと思っています。それから私は、このような
valueE = (raw_input("Enter color number"))
valueE = int(valueE)
print nodes[0].color+valueE
私はこのまたはこのようなものをどのように行うことができますように、その変数にアクセスできるようにしたいですか?
'nodes [0] .color'とは何ですか? –