我想從字典中賦值給變量,但變量保持不變。該值是另一個字典。字典沒有賦值給變量
我用來生成字典的代碼可以在這裏找到:http://pastebin.com/Q2Hc8Ktp
我自己寫的,並測試它沒有這個問題。
這是我試圖從字典中複製字典的代碼片段。
_classes = {}
def populateClasses():
print "Classes Exist"
cp = Preferences(''.join([resource_path,"resources.ini"]))
print cp
_classes = cp.getPreferences()['Classes']
populateClasses()
print _classes
當我打印出來CP它顯示了正確的數據,但是當我嘗試打印_classes那隻能說明{}
注:從內部功能工作正常打印_classes但不能從功能外。 _classes是在全球範圍內
CNC中
這裏定義也有一些樣本數據:
[Classes]
Wizard = Arcana, Bluff
Warrior = Endurance, Intimidate
Ranger = Nature, Perception
Bard = Heal, History
使用'全球_classes = {} http://stackoverflow.com/questions/423379/using-global-variables-in-a-function-other-than-the-one-that-created-他們 – 2013-05-12 06:27:26