shutil.copytree()
当文件名中有空格时我不能使用。我想我必须使用原始字符串 -->r'your-string'
但是如何实现呢?
编辑:这是我的代码。
import os
import shutil
import sys
usb_folder = os.listdir("/media/kame")
# create path okay
path_ = r'/media/kame/' + str(usb_folder)[2:-2]
# copy files
path_2 = path_ + '/main'
#try:
# os.makedirs(path_2)
#except:
# pass
shutil.copytree('/home/kame/Desktop/main/bilder/geschichte',path_2)
这是错误:
File "/usr/lib/python2.7/shutil.py", line 208, in copytree
raise Error, errors
shutil.Error: [('/home/kame/Desktop/main/bilder/geschichte/Screenshot from 2014-12-24 11:09:06.png', '/media/kame/INTENSO/main/Screenshot from 2014-12-24 11:09:06.png', "[Errno 22] invalid mode ('wb') or filename: '/media/kame/INTENSO/main/Screenshot from 2014-12-24 11:09:06.png'"), ('/home/kame/Desktop/main/bilder/geschichte/Screenshot from 2014-12-22 21:41:28.png'