資源簡介
Python 自定義FTP功能 實例源碼
代碼片段和文件信息
#!/usr/bin/env?python
#?-*-?coding:utf-8?-*-
“Program?for?ftp?server“
from?socketserver?import?*
from?time?import?*
import?os
import?loginauth
import?traceback
import?subprocess
import?codecs
import?logging
def?GetParentPath(strPath):??
????if?not?strPath:??
????????return?None;??
????lsPath?=?os.path.split(strPath);??
????if?lsPath[1]:??
????????return?lsPath[0];??
????lsPath?=?os.path.split(lsPath[0]);??
????return?lsPath[0];
def?ReadFile(filePathencoding=“utf-8“):
????????with?codecs.open(filePath“r“encoding)?as?f:
????????????return?f.read()
?
class?MyFtp(StreamRequestHandler):
?????????????????
??def?handle(self):
????????logger?=?logging.getLogger(“FTP“)
????????logger.setLevel(logging.DEBUG)
????????#?create?file?handler?which?logs?even?debug
- 上一篇:Python xlwt 創建xls文件
- 下一篇:python 簡易計算器
評論
共有 條評論