我有一个程序,可以对excel文件进行一些操作。我正在尝试为此创建一个GUI。我需要用户浏览他的计算机并选择他要通过该过程的excel文件。但我无法将PyQT文件打开器的地址提供给熊猫。熊猫和numpy以及其他所有内容均已导入。我只是无法链接这两个。
def selectFile(self):
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
fileName, _ = QFileDialog.getOpenFileName(self,"Open File", "","All Files (*);;Excel Files (*.xlsx)", options=options)
# print(fileName)
if fileName:
# df=pd.read_excel(fileName,Header=None)
self.variableOne = fileName
return self.variableOne
print(self.variableOne)
address=''
df=pd.read_excel(selectFile(address), header=None)
data=np.asarray(df)
我收到错误消息:
fileName, _ = QFileDialog.getOpenFileName(self,"Open File", "","All Files (*);;Excel Files (*.xlsx)", options=options)
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'