使用反斜杠显示QLabel

2024-09-29 00:19:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个场景,路径(在我的程序中设置)存储在json文件中,我需要在QLabel上显示它

# self.progSettings is a dictionary containing the json content

labelStr = self.progSettings['testReportPath']

# labelStr now contains "C:\temp\testreports"
self.pathLabel = QLabel(labelStr) # No escape characters -> problem

为了正确显示路径,我需要避开反斜杠,但我不知道如何轻松地以“正确”的方式完成

谢谢 尼古拉斯


Tags: 文件theself路径程序jsondictionaryis