Python 3.x PermissionError:[WinError 5]访问被拒绝
我是Python的初学者。我正在使用多处理来批处理程序,例如从主机PC到远程PC的xcopy。我遇到了一个许可错误,例如*复制\u相同\u访问*。任何帮助都会很有帮助 IDE环境:强>Python 3.x PermissionError:[WinError 5]访问被拒绝,python-3.x,multiprocessing,file-permissions,access-denied,Python 3.x,Multiprocessing,File Permissions,Access Denied,我是Python的初学者。我正在使用多处理来批处理程序,例如从主机PC到远程PC的xcopy。我遇到了一个许可错误,例如*复制\u相同\u访问*。任何帮助都会很有帮助 IDE环境: 开普勒 Python-3.x 错误消息 client.csv: 192.168.10.100,测试 192.168.10.101,测试 192.168.10.102,测试 我将修改多分发文件方法以打开/读取文件 来源: def multi_distribute_file(lo, server, dirpath,
- 开普勒
- Python-3.x
- 192.168.10.100,测试
- 192.168.10.101,测试
- 192.168.10.102,测试
def multi_distribute_file(lo, server, dirpath, filename, subdir):
lo.acquire()
pathname = os.path.join(dirpath, filename)
print("Read from {}".format(pathname))
with open(pathname, 'rb') as inFile:
buffer = inFile.read()
l = re.findall(r"[\w']+",subdir)
m = re.findall(r"[\w']+",dirpath)
cnt_l = len(l)
cnt_m = len(m)
remotepath = "//%s/%s" % (server.addr, server.path)
if(cnt_m > cnt_l):
for j in range(cnt_m - cnt_l):
remotepath += "/%s" % (m[cnt_l + j])
remotepath += "/%s" % (filename)
print ("Write to {}".format(remotepath))
with open(remotepath, 'wb') as outFile:
outFile.write(buffer)
lo.release()
修改:添加缓冲区参数
def multi_distribute_file(server, dirpath, filename, subdir, buffer):
#lo.acquire()
#pathname = os.path.join(dirpath, filename)
#print("Read from {}".format(pathname))
#with open(pathname, 'rb') as inFile:
# buffer = inFile.read()
l = re.findall(r"[\w']+",subdir)
m = re.findall(r"[\w']+",dirpath)
cnt_l = len(l)
cnt_m = len(m)
remotepath = "//%s/%s" % (server.addr, server.path)
if(cnt_m > cnt_l):
for j in range(cnt_m - cnt_l):
remotepath += "/%s" % (m[cnt_l + j])
remotepath += "/%s" % (filename)
print ("Write to {}".format(remotepath))
with open(remotepath, 'wb') as outFile:
outFile.write(buffer)
#lo.release()
def multi_distribute_file(lo, server, dirpath, filename, subdir):
lo.acquire()
pathname = os.path.join(dirpath, filename)
print("Read from {}".format(pathname))
with open(pathname, 'rb') as inFile:
buffer = inFile.read()
l = re.findall(r"[\w']+",subdir)
m = re.findall(r"[\w']+",dirpath)
cnt_l = len(l)
cnt_m = len(m)
remotepath = "//%s/%s" % (server.addr, server.path)
if(cnt_m > cnt_l):
for j in range(cnt_m - cnt_l):
remotepath += "/%s" % (m[cnt_l + j])
remotepath += "/%s" % (filename)
print ("Write to {}".format(remotepath))
with open(remotepath, 'wb') as outFile:
outFile.write(buffer)
lo.release()
def multi_distribute_file(server, dirpath, filename, subdir, buffer):
#lo.acquire()
#pathname = os.path.join(dirpath, filename)
#print("Read from {}".format(pathname))
#with open(pathname, 'rb') as inFile:
# buffer = inFile.read()
l = re.findall(r"[\w']+",subdir)
m = re.findall(r"[\w']+",dirpath)
cnt_l = len(l)
cnt_m = len(m)
remotepath = "//%s/%s" % (server.addr, server.path)
if(cnt_m > cnt_l):
for j in range(cnt_m - cnt_l):
remotepath += "/%s" % (m[cnt_l + j])
remotepath += "/%s" % (filename)
print ("Write to {}".format(remotepath))
with open(remotepath, 'wb') as outFile:
outFile.write(buffer)
#lo.release()