python 怎么实现两台服务器上批量复制文件

python 怎么实现两台服务器上批量复制文件,第1张

1、把excel里文件名那一列复制,粘进一个空白的文本文件,命名为filelisttxt,上传到服务器。
2、在服务器上使用脚本导出,python脚本 fileCppy 。
代码示例:
#! python
#coding:utf-8

##!/usr/bin/python
# Filename : fileCppy
import sys
import os
import shutil

fileList='filelisttxt'
targetDir='files'

filedir = open(fileList)
line = filedirreadline()
log = open('runninglog','w')
while line:
line = linestrip('\n');
basename = ospathbasename(line)
exists = ospathexists(line)
if exists :
print 'copy '+line+' to '+osgetcwd()+'/'+targetDir+'/'+basename
logwrite('copy '+line+' to '+osgetcwd()+'/'+targetDir+'/'+basename+'\r\n')
shutilcopy(line,targetDir+'/'+basename)
else:
print line+' not exists'
logwrite(line+' not exists'+'\r\n')
line = filedirreadline()
logclose()

用Django在腾讯云上部署过,可以,但是得把runserver的参数调整一下,另外在腾讯云上设置下,把需要将使用的端口开放。另外你说的两个线程的问题,如果你的web服务不访问正在处理数据那个线程,我猜是可以的=。=没试过,你可以在本地先测试一下


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/10624771.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-10
下一篇 2023-05-10

发表评论

登录后才能评论

评论列表(0条)

保存