今天在用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(*)")
参考文献
[1]. Open and save image file using menubar in PyQt5. https://stackoverflow.com/questions/50313410/open-and-save-image-file-using-menubar-in-pyqt5
[2]. pyqt5 从本地选择图片 并显示在label上. https://blog.csdn.net/qq_32973061/article/details/81139689