import ftplib
from ftplib import FTP
ftp = FTP("192.168.0.112")
ftp.login(user=username, passwd=password)
def ftp_remote_path_is_directory(ftp, remote_path):
current_path = ftp.pwd()
try:
ftp.cwd(remote_path)
except ftplib.error_perm as e:
if str(e).startwith("550"):
return False
else:
print(f"other error check error code{str(e)}")
return None
ftp.cwd(current_path)
return True
def ftp_remote_path_is_file(ftp, remote_path):
current_path = ftp.pwd()
try:
ftp.cwd(remote_path)
except ftplib.error_perm as e:
if str(e).startwith("550"):
return True
else:
print(f"other error check error code{str(e)}")
return None
ftp.cwd(current_path)
return False
python ftplib写一个判断远端路径是文件还是文件夹
于 2024-10-30 15:17:29 首次发布
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Python3.11
Conda
Python
Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本
829

被折叠的 条评论
为什么被折叠?



