【发布时间】:2017-08-06 16:04:29
【问题描述】:
几分钟前我的功能运行良好。没有修改代码,只是安装了 PyAudio。我根据主题得到错误。从命令行或IDE运行它都没有关系,同样的错误。有什么想法吗?
def DataFinder():
#imports and initialize
import pandas as pd
import tkinter as tk
finder = tk.Tk()
finder.withdraw()
__dataFlag = False
#ask user to select a file
__path = tk.filedialog.askopenfilename()
#check the extension to handle reader
#for csv files
if __path.endswith('.csv')==True:
df = pd.read_csv(__path,header=0)
return df
__dataFlag = True
#and for excel files
elif __path.endswith('.xls')==True:
df = pd.read_excel(__path,header=0)
return df
__dataFlag = True
#if a file is not a supported type display message and quit
else:
__dataFlag = False
#check if there is a data to be returned
if __dataFlag==True:
return df
else:
print('The file format is not supported in this version.')
【问题讨论】:
标签: python-3.x tkinter