當我嘗試'獲取'我的遠程文件時,我得到以下結果。我可以打印,我知道這些文件在那裏。我是否需要將文件構建到列表中?Python TypeError無法連接str和'xxxxx'對象
file_list_attr = sftp.listdir_attr()
for pfile in file_list_attr:
if DT.datetime.fromtimestamp(pfile.st_mtime) > yesterday:
# print pfile
localfile = path + "\\" + pfile
sftp.get(pfile,localfile)
Traceback (most recent call last):
File "C:\Documents and Settings\tyoffe\Desktop\FTP", line 41, in <module>
localfile = path + "\\" + pfile
TypeError: cannot concatenate 'str' and 'SFTPAttributes' objects
這個問題基本上是相同的,因爲這http://stackoverflow.com/questions/3532873/python-cannot-concatenate-str並且長對象,所以你可能會發現閱讀答案也是有用的。 –