PyQt 打开文件夹路径

from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QDesktopServices

    def button_show_dir(self):
        default_dir = "./report_pdf"
        show_dirPath = 0
        if self.dir_choose == 0:
            show_dirPath = default_dir
        else:
            show_dirPath = self.dir_choose

        url = QUrl.fromLocalFile(show_dirPath)
        if url:
            print("选择的文件夹路径:", show_dirPath)
        else:
            print("未选择文件夹")
        QDesktopServices.openUrl(url)

你可能感兴趣的:(pyqt,python,前端,知识点)