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

在 Python 中將數據附加到 FTP 服務器上的文件

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

問題描述

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

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()

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

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)

這篇關于在 Python 中將數據附加到 FTP 服務器上的文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

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:“浮動對象不可下標)
主站蜘蛛池模板: 国产一区二区三区色淫影院 | 91 在线| 北条麻妃一区二区三区在线视频 | 天天看天天操 | 亚洲第一区国产精品 | 男女免费在线观看视频 | 亚洲一区| 97精品超碰一区二区三区 | 国产视频一区二区 | 日韩一区二区三区在线播放 | 国产日韩一区二区三区 | 狠狠爱网址 | 久久久久九九九女人毛片 | 国产一区二区免费在线 | 亚洲午夜精品一区二区三区他趣 | 欧美视频一区 | 在线视频a | 97精品超碰一区二区三区 | 91av入口 | www.久久 | 天天干干 | 国产精品成人av | 精品免费国产一区二区三区 | 日韩精品一区二区久久 | 国产精品视频在线播放 | 最近中文字幕免费 | 国产免费一区二区三区最新6 | 欧美精品一区二区三区在线播放 | 色av一区 | 婷婷色国产偷v国产偷v小说 | 人成在线 | 亚洲视频区 | 华人黄网站大全 | 欧美日韩在线一区二区 | 久久99国产精一区二区三区 | 91看片网址| 久久夜视频 | 91香蕉嫩草| 韩国av一区二区 | 黄色片av| 天堂成人国产精品一区 |