我正在尝试将变量 dirpath 传递给 export_data() 函数。双击小部件上的按钮即可导出数据。为什么 dirpath 打印为:
`<Tkinter.Event instance at 0x8ade56c>`
而不是实际路径?
def export_data(dirpath):
print 'exporting...'
print str(dirpath)
os.mkdir('/home/bigl/Desktop/Library')
shutil.copytree(dirpath, output_path)
当我运行我的代码时,我得到了错误
exporting...
<Tkinter.Event instance at 0x8ade56c>
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1413, in __call__
return self.func(*args)
File "/media/LOFTUS/20130308_searchtest.py", line 44, in export_data
shutil.copytree(dirpath, output_path)
File "/usr/lib/python2.7/shutil.py", line 169, in copytree
names = os.listdir(src)
TypeError: coercing to Unicode: need string or buffer, instance found