久久久久久久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:“浮動對象不可下標)
主站蜘蛛池模板: 三级理论片| 黄网站免费在线观看 | 日韩一级黄色片 | 奇米av | 在线视频亚洲 | 亚洲黄色免费 | 日本国产在线观看 | 小sao货撅起屁股扒开c微博 | 青青草国产成人av片免费 | 午夜激情福利视频 | 黑人精品xxx一区一二区 | 一区二区三区免费观看 | 三级黄网站 | 国产精品123区 | 中文字幕亚洲精品 | 一区| 91国内在线 | 91免费黄| 操小妹影院| 黄色天天影视 | 亚洲欧洲av | 国产男女无遮挡猛进猛出 | 第一福利视频 | 欧美日韩在线一区 | 欧美日本在线观看 | 欧美一级特黄视频 | 精品一区二区三区三区 | 精品国产伦一区二区三区 | 中文字幕在线日韩 | 51成人网| 超碰av在线播放 | 国产一区视频在线 | 日韩亚洲欧美在线观看 | 久久成人免费视频 | 在线婷婷 | 国产伦精品一区二区三区免费视频 | 成人在线网 | 一级做a视频 | 国产小视频在线观看 | av大片在线观看 | 视频一区在线播放 |