我已经在论坛中查看了与此类似的几个帖子,但出现了相同的错误,但仍然无法修复它。我收到 IOError: [Errno 13] Permission denied: 'C:/..../.' 使用 shutil.copy() 时。这是代码:
import subprocess, os, shutil
for i in range(1,3):
path = 'C:/Users/TEvans/Desktop/Testing/slope%d' % i
if not os.path.exists(path):
os.makedirs(path)
os.chdir(path)
for j in range(1,4):
path1 = 'C:/Users/TEvans/Desktop/Testing/slope%d/r%d' % (i, j)
if not os.path.exists(path1):
os.makedirs(path1)
src = 'C:/Users/TEvans/Desktop/Testing/PP%d/S%d' % (i, j)
dst = 'C:/Users/TEvans/Desktop/Testing/slope%d/r%d' % (i, j)
shutil.copy(src, dst)
Traceback (most recent call last):
File "sutra.py", line 14, in <module>
shutil.copy(src, dst)
File "C:\Python27\lib\shutil.py", line 117, in copy
copyfile(src, dst)
File "C:\Python27\lib\shutil.py", line 82, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 13] Permission denied: 'C:/Users/TEvans/Desktop/Testing/PP1/S1'