我试图创建多个子目录和文件移动到这些子目录,子目录下的文件的是哪个环路的数量,这是我所:创建多个目录
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