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

在 Python 中使用 ftplib 上傳文件之前更改服務(wù)器上

Change directory on server before uploading files with ftplib in Python(在 Python 中使用 ftplib 上傳文件之前更改服務(wù)器上的目錄)
本文介紹了在 Python 中使用 ftplib 上傳文件之前更改服務(wù)器上的目錄的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有這段代碼,但我不知道如何在上傳文件之前更改服務(wù)器上的目錄.

I have this code, but I can't figure out how to change directory on the server before uploading files.

誰能幫幫我?

import ftplib
import os

server = 'enter your servername here'
username = 'root'
password = 'passowrd'
myFTP = ftplib.FTP(server, username, password)
myPath = r'C:path_of_the_folder_goes_here'
def uploadThis(path):
    files = os.listdir(path)
    os.chdir(path)
    for f in files:
        if os.path.isfile(path + r'{}'.format(f)):
            fh = open(f, 'rb')
            myFTP.storbinary('STOR %s' % f, fh)
            fh.close()
        elif os.path.isdir(path + r'{}'.format(f)):
            myFTP.mkd(f)
            myFTP.cwd(f)
            uploadThis(path + r'{}'.format(f))
    myFTP.cwd('..')
    os.chdir('..')
uploadThis(myPath)

推薦答案

使用 FTP.cwd方法:

myFTP.cwd('/remote/path')

打電話之前

uploadThis(myPath)

這篇關(guān)于在 Python 中使用 ftplib 上傳文件之前更改服務(wù)器上的目錄的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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:“浮動對象不可下標(biāo))
主站蜘蛛池模板: 欧美一级黄色免费 | 国产高清视频在线观看播放 | 国产精品国产三级国产aⅴ无密码 | 中文字幕在线不卡播放 | 中文在线日韩 | 美女视频黄的免费 | 日韩精品免费在线观看 | 亚洲国产日韩一区 | 一级黄色片美国 | 国产98色在线 | 日韩 | 美女网站视频免费黄 | 日韩亚洲欧美一区 | 一级免费a | 亚洲国产精品一区 | 亚洲成人黄色 | 久久99国产精一区二区三区 | 91精品国产色综合久久 | 欧美日韩成人影院 | 日韩成人在线网站 | 97av在线| 欧美激情国产日韩精品一区18 | 日韩激情网 | 亚洲精品永久免费 | 日本在线中文 | 女女百合av大片一区二区三区九县 | 狠狠操狠狠操 | 久久中文字幕一区 | 日韩在线一区二区三区 | 国产成人精品午夜 | 免费黄色成人 | 夜夜艹| 成人亚洲精品久久久久软件 | 狠狠干夜夜草 | 欧美黑人一区 | av资源在线看| 亚洲九九| 99久久久久久久 | 国产特级毛片aaaaaa | 国产精品一区二区三区在线 | 日日操操 | 亚洲精品乱码久久久久久久久久 |