-1
我有一個字典的實例。我怎樣才能修改字典中的字典,由字典中的鍵?python,如何修改類實例的字典屬性
class myclass:
def __init__(self):
self.mydict = {'number':0}
def myfunction(foo):
foo.mydict[number] += 10 #<- doesnt work gives me 'global name number not defined'
instance = myclass()
myfunction(instance)
希望你能幫助我, 謝謝!
bwaaaa。但當然,在這裏4:20,可能會更好地稱它爲夜晚...... thx很多 – 2013-02-09 03:19:55