今天爱分享给大家带来pyqt5 TypeError: getOpenFileName(parent: QWidget = None, caption: str = ”, directory: str = ”, fil【解决办法】,希望能够帮助到大家。
今天在用pyqt5打开文件的时候,出现了下面的错误:
Traceback (most recent call last): File "/Users/admin/PycharmProjects/test_qt/src/tooth.py", line 20, in openimage imgName, imgType = QFileDialog.getOpenFileName( '选择文件', '', "*.jpg;;*.png;;All Files(*)") TypeError: getOpenFileName(parent: QWidget = None, caption: str = '', directory: str = '', filter: str = '', initialFilter: str = '', options: Union[QFileDialog.Options, QFileDialog.Option] = 0): argument 1 has unexpected type 'str'
解决方法
imgName, imgType = QFileDialog.getOpenFileName(None,'选择文件','',"*.jpg;;*.png;;All Files(*)")