我試圖創建多個子目錄和文件移動到這些子目錄,子目錄下的文件的是哪個環路的數量,這是我所:創建多個目錄
for x in range(1,20):
os.makedirs('{}/'.format(replace)+str(x)+'/')
shutil.move(filename,'{}/'.format(replace)+str(x)+'/')
shutil.move(filename1,'{}/'.format(replace)+str(x)+'/')
我得到這個錯誤:
File "testdraft.py", line 285, in findReplace
shutil.move(f, '{}/'.format(replace)+str(x)+'/')
File "/usr/lib/python2.7/shutil.py", line 284, in move
if _samefile(src, dst):
File "/usr/lib/python2.7/shutil.py", line 58, in _samefile
return os.path.samefile(src, dst)
File "/usr/lib/python2.7/posixpath.py", line 162, in samefile
s1 = os.stat(f1)
TypeError: coercing to Unicode: need string or buffer, file found
感謝您的幫助
請告訴我們什麼' f'要麼打印出它的'repr',要麼顯示產生它的代碼,或者理想的是兩者。否則,這不是[完整示例](http://stackoverflow.com/help.mcve),只能通過猜測來回答。 – abarnert 2014-11-07 01:34:48