Python 如何使用pickle在QDialog上显示字典?

Python 如何使用pickle在QDialog上显示字典?,python,dictionary,pickle,Python,Dictionary,Pickle,在学习python时,我在显示字典时遇到了问题。我的字典得到保存和检索,但没有显示在Qdialog上。 我在下面附上了我的代码。请帮我解决这个问题 def button_click(self): aa = {} aa["Name"] = str(self.lineEdit_name.text()) aa["Address"] = str(self.lineEdit_address.text()) return aa print aa def retri

在学习python时,我在显示字典时遇到了问题。我的字典得到保存和检索,但没有显示在Qdialog上。 我在下面附上了我的代码。请帮我解决这个问题

def button_click(self):
    aa = {}
    aa["Name"] = str(self.lineEdit_name.text())
    aa["Address"] = str(self.lineEdit_address.text())

    return aa
    print aa

def retrieve(self):
    aa = self.use_file()
    if (aa != None):      
        self.lineEdit_name.setText(aa[self.lineEdit_name.text()])
        self.lineEdit_address.setText(aa["Address"])

    return aa

def save_file(self, parent=None):
    bbb = self.button_click()
    filename = QtGui.QFileDialog.getSaveFileName(parent, 'Save File', '/home/reshma/untitled.txt', filter= '*.txt')
    fileobj = open(filename,"w")
    pickle.dump(bbb, fileobj)
    #fileobj.close()

    print bbb

def use_file(self, parent=None):
    bbb = self.button_click()
    filename = QtGui.QFileDialog.getOpenFileName(parent, 'Open File', '/home/reshma/untitled.txt', filter= '*.txt')

    if os.path.isfile(filename):
        file = open(filename, "r+")
        infile= pickle.load(file)
        print infile
        return infile
    else:
        return None

aa
不是全局的(所以意思是
self.aa={}
)!对不起,先生,您能详细解释一下吗。我没有得到。将所有
aa
替换为
self.aa
。如果没有任何
self
对象,为什么要使用类?存储到temp并调用temp值(当然
为空