使用PySide2(基本上是PyQt5),我试图在一个QLabel中setText,该QLabel的字符串中包含字符'<;'和'>;'。但是,由于这些字符用于修改字体,因此这两个字符中的任何内容都将消失。我试着用反斜杠来逃避,但似乎还是没用。。。在
如何在QLabel中显示“<;”和“>;”字符?在
编辑:下面是我的代码在做什么(只是抓住了重要的部分):# color and text get set at various places in my code (len_infs is just the length of the
# influence item list - hopefully that's obvious...)
#
color = '#FF0000'
text = 'Influence count <%d> exceeds minimum row count...' %len_infs
# status_label is a QLabel that displays the text in the appropriate color within the label
#
status_label.setText('status: %s' %(color, text))
如您所见,我根据Ekhurvo的建议在字符串中使用了<和>,但在生成的QLabel文本中没有得到'<;'或'>;'
我要它打印status: Influence count <7> exceeds minimum row count...
但它实际上打印status: Influence count <7> exceeds minimum row count...
在这两种情况下,“status:”都是白色的,而其余的则是预期的红色。在
注意:在字符串中使用''会导致status: Influence count exceeds minimum row count...
我还需要做什么才能正确格式化字符串?在