我试图复制一个文件夹,其中有许多特殊字符文件,如(misc\u wall\u stone\u bump)äöüáß日本語їнськаייִדיש中氖ÄÖÜß.(畅通节能法) (试验)äöü ייִדיש日本語їнськаייִדיש中文ÄÖÜß.(巴布亚新几内亚) 转到另一个文件夹。但它正在失败
[Errno 22] invalid mode ('rb') or filename:'misc_wall_stone_bump\xc3\xa4\xc3\xb6\xc3\xbc\xc3\xa1\xc3\x9f????????????????ne\xc3\x84\xc3\x96\xc3\x9c\xc3\x9f.tif'
我们使用的是Python2.7
课程:
def rttCopyTree(src, dst, nolog=False):
if not os.path.exists(dst):
os.makedirs(dst)
names = os.listdir(src)
for name in names:
srcname = os.path.join(src, name)
dstname = os.path.join(dst, name)
try:
if os.path.isdir(srcname):
rttCopyTree(srcname, dstname, True)
else:
shutil.copy(srcname, dstname)
except (IOError, os.error) as why:
rttFatal("failed to copy " + srcname + " to " + dstname + "Error: " + str(why))
if not nolog:
test.log("End of copying files.")
程序应将源文件夹中的所有文件复制到目标文件夹
目前没有回答
相关问题 更多 >
编程相关推荐