久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Python 中將數(shù)據(jù)附加到 FTP 服務(wù)器上的文件

Append data to file on FTP server in Python(在 Python 中將數(shù)據(jù)附加到 FTP 服務(wù)器上的文件)
本文介紹了在 Python 中將數(shù)據(jù)附加到 FTP 服務(wù)器上的文件的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我每 6 秒將值附加到日志文件中.每 30 秒,我將此日志作為文件傳輸?shù)?FTP 服務(wù)器.但不是傳輸整個(gè)文件,我只想將收集到的數(shù)據(jù)附加到我服務(wù)器上的文件中.我無法弄清楚如何打開服務(wù)器文件然后附加值.

I'm appending values to a log file every 6th second. Every 30 sec I'm transferring this log to an FTP server as a file. But instead of transfering the whole file, I just want to append the collected data to the file on my server. I haven't been able to figure out how to open the server file and then append the values.

到目前為止我的代碼:

session = ftplib.FTP(authData[0],authData[1],authData[2])
session.cwd("//"+serverCatalog()+"//") # open server catalog
file = open(fileName(),'rb')

with open(fileName(), 'rb') as f:
     f = f.readlines()
         for line in f:
             collected = line
           
           # In some way open server file, write lines to it
           session.storbinary('STOR ' + fileName(), open(fileName(), 'a'), 1024)
           file.close()
           session.quit()

相反,我是否必須下載打開并附加的服務(wù)器文件,然后將其發(fā)回?

Instead, do I have to download the server file open and append, then send it back?

以上是我的問題,完整的解決方案如下:

Above was my question, the full solution is below:

session.cwd("//"+serverCatalog()+"//") # open server catalog
localfile = open("logfile.txt",'rb')
session.storbinary('APPE serverfile.txt', localfile)
localfile.close()

推薦答案

使用 APPE 而不是 STOR.

來源:http://www.gossamer-threads.com/lists/python/python/22960 (鏈接到 web.archive.org)

這篇關(guān)于在 Python 中將數(shù)據(jù)附加到 FTP 服務(wù)器上的文件的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Why I cannot make an insert to Python list?(為什么我不能插入 Python 列表?)
Insert a column at the beginning (leftmost end) of a DataFrame(在 DataFrame 的開頭(最左端)插入一列)
Python psycopg2 not inserting into postgresql table(Python psycopg2 沒有插入到 postgresql 表中)
list extend() to index, inserting list elements not only to the end(list extend() 索引,不僅將列表元素插入到末尾)
How to add element in Python to the end of list using list.insert?(如何使用 list.insert 將 Python 中的元素添加到列表末尾?)
TypeError: #39;float#39; object is not subscriptable(TypeError:“浮動(dòng)對(duì)象不可下標(biāo))
主站蜘蛛池模板: 色狠狠桃花综合 | 国产一区亚洲 | 九九精品网 | 免费精品| 草草影院ccyy| 在线播放日韩 | 第一福利社区1024 | 午夜影院在线观看 | 亚洲精品一区二三区不卡 | 日本一区二区三区免费观看 | 在线观看黄色大片 | 亚洲精品一二三区 | 黄视频网站免费观看 | 国产日韩欧美一区 | 91精品国产91久久久久游泳池 | 国产资源视频 | 日韩成人一区 | 成人精品一区二区三区 | 亚洲欧洲一区 | 久久九九99| 在线观看视频福利 | www.免费看片.com | 综合久| 中文字幕 视频一区 | 成人午夜精品 | 日韩精品在线播放 | 久草综合在线 | 国产一区二区三区四区hd | 国产在线视频三区 | 狠狠的干狠狠的操 | 九色在线视频 | 91精品欧美久久久久久久 | 欧美成人一区二免费视频软件 | 999久久久 | 国内成人免费视频 | 在线观看视频一区二区三区 | 国产色婷婷久久99精品91 | 国产精品一区二区视频 | 欧美一级欧美三级在线观看 | 国产欧美日韩精品一区 | 国产精品久久久一区二区三区 |