Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pyqt:QMessageBox输出中的变量值?_Python_String_Qmessagebox - Fatal编程技术网

Python pyqt:QMessageBox输出中的变量值?

Python pyqt:QMessageBox输出中的变量值?,python,string,qmessagebox,Python,String,Qmessagebox,现在,我正在QMessageBox中显示一个包含文本的窗口。它可以准确地工作并显示文本 profBox = QMessageBox() QMessageBox.about(self,'Profile', "Gender: <br /> Age: < br />") #Ideal output is gender: F (stored in a variable) and Age: X (also stored in a variable) profBox=QMess

现在,我正在QMessageBox中显示一个包含文本的窗口。它可以准确地工作并显示文本

 profBox = QMessageBox()
 QMessageBox.about(self,'Profile', "Gender: <br /> Age: < br />") #Ideal output is gender: F (stored in a variable) and Age: X (also stored in a variable)
profBox=QMessageBox()
QMessageBox.about(self,'Profile',“性别:
年龄:
”)理想的输出是性别:F(存储在变量中)和年龄:X(也存储在变量中)
我想在性别和年龄之后包含某些变量的值,但我对包含变量值的语法很好奇。我要先把它们转换成字符串吗?由于.about框最多只能接受三个参数,如何包含它们

谢谢大家!

使用:


为什么要使用
QMessageBox.about(self)
而不是
self.about(…)
profBox.about(…)
>>> gender = 'M'
>>> age = 33

>>> "Gender: {}<br /> Age: {}< br />".format(gender, age)
'Gender: M<br /> Age: 33< br />'
>>> "Gender: %s<br /> Age: %s< br />" % (gender, age)
'Gender: M<br /> Age: 33< br />'