分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 网页技术

ORA-03113:通信通道的文件结尾-完美解决方案

发布时间:2023-09-06 01:16责任编辑:赖小花关键词:暂无标签

利用FTP服务器下载目录

import os,sysfrom ftplib import FTPfrom mimetypes import guess_typenonpassive = False ????????????????????????????????????????????????????????#passive FTP by defaultremotesite = ‘192.168.191.1‘remotedir = ‘.‘ ???????????????????????????????????????????????????????????#FTP的路径remoteuser = () ???????????????????????????????????????????????????????????#因为我没设置密码,所以为空集localdir = ‘.‘ ????????????????????????????????????????????????????????????#本地路径clean_all = input( ‘Clean local directory first? ‘)[:1] in [‘y‘,‘Y‘] ??????#是否清除本地目录所有文件#连接PFTPprint(‘connecting...‘)connection = FTP(remotesite)connection.login(*remoteuser)connection.cwd(remotedir)if nonpassive: ???connection.set_pasv(False) ????????????????????????????????????????????#most servers do passive#清除if clean_all: ???for localname in os.listdir(localdir): ???????try: ???????????print(‘deleting local‘,localname) ???????????os.remove(os.path.join(remotedir,localname)) ???????except: ???????????print(‘cannot delete‘, localname)count = 0remotefiles = connection.nlst()#只能下载目录中的文件,不能下载目录中的目录for remotename in remotefiles[:5]: ???if remotename in (‘.‘,‘..‘) or not ‘.‘ in remotename:continue ????????????#判断是否目录,这里根据实际情况更改 ???mimetype,encoding = guess_type(remotename) ???mimetype = mimetype or ‘?/?‘ ???mimetype = mimetype.split(‘/‘)[0] ???localpath = os.path.join(localdir,remotename) ???print(‘downing‘,remotename,‘to‘,localpath,end=‘ ‘) ???print(‘as‘,mimetype,encoding or ‘‘) ???#保存文件 ???if mimetype == ‘text‘ and encoding == None: ???????localfile = open(localpath,‘w‘,encoding=connection.encoding) ???????callback = lambda line: localfile.write(line + ‘\n‘) ???????connection.retrlines(‘RETR ‘+remotename,callback) ???else: ???????localfile = open(localpath,‘wb‘) ???????connection.retrbinary(‘RETR ‘+remotename,localfile.write) ???localfile.close() ???count += 1connection.quit()print(‘Done:‘,count,‘file download.‘)

利用FTP服务器上传目录

import os,sysfrom ftplib import FTPfrom mimetypes import guess_typenonpassive = False ????????????????????????????????????????????????????????#passive FTP by defaultremotesite = ‘192.168.191.1‘remotedir = ‘RRR‘ ???????????????????????????????????????????????????????????#FTP的路径remoteuser = () ???????????????????????????????????????????????????????????#因为我没设置密码,所以为空集localdir = ‘TTT‘ ????????????????????????????????????????????????????????????#本地路径clean_all = input( ‘Clean local directory first? ‘)[:1] in [‘y‘,‘Y‘] ??????#是否清除远程目录所有文件#连接PFTPprint(‘connecting...‘)connection = FTP(remotesite)connection.login(*remoteuser)connection.cwd(remotedir)if nonpassive: ???connection.set_pasv(False) ????????????????????????????????????????????#most servers do passive#清除if clean_all: ???for remotename in connection.nlst(): ???????try: ???????????print(‘deleting local‘,remotename) ???????????connection.delete(remotename) ???????except: ???????????print(‘cannot delete‘, remotename)count = 0localfiles = os.listdir(localdir)#只能下载目录中的文件,不能下载目录中的目录for localname in localfiles[:5]: ???mimetype,encoding = guess_type(localname) ???mimetype = mimetype or ‘?/?‘ ???mimetype = mimetype.split(‘/‘)[0] ???localpath = os.path.join(localdir,localname) ???print(‘downing‘,localname,‘to‘,localpath,end=‘ ‘) ???print(‘as‘,mimetype,encoding or ‘‘) ???#保存文件 ???if mimetype == ‘text‘ and encoding == None: ???????localfile = open(localpath,‘rb‘) ???????connection.storlines(‘RETR ‘+localname,localfile) ???else: ???????localfile = open(localpath,‘rb‘) ???????connection.storbinary(‘RETR ‘+localname,localfile) ???localfile.close() ???count += 1connection.quit()print(‘Done:‘,count,‘file uploaded.‘)

ORA-03113:通信通道的文件结尾-完美解决方案

原文地址:http://www.cnblogs.com/linbo3168/p/7649711.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved