当前位置: 首页 > news >正文

做网站电销个人网站规划书模板

做网站电销,个人网站规划书模板,河北省建设监理协会网站,多语言企业网站源码仅描述基础要点,备忘。 python自带ftplib库,可实现ftp读写。 1 要点 ftp未使用默认端口21时,需显示指定端口。ftp路径带有中文,可能需要设置ftp的encoding属性为 gbk。ftplib不支持递归创建目录,需手动创建层级目录…

仅描述基础要点,备忘。

python自带ftplib库,可实现ftp读写。

1 要点

  • ftp未使用默认端口21时,需显示指定端口。
  • ftp路径带有中文,可能需要设置ftp的encoding属性为 gbk。
  • ftplib不支持递归创建目录,需手动创建层级目录。

2 代码

2.1 下载文件

import os
from ftplib import FTPftp_server = '192.168.162.128'
ftp_port = 31  # FTP默认端口是21
uname = 'test'
upwd= 'test'
# 匿名访问是 用户名是anonymous, 密码随便填写remote_file_path = '/haha/hi.txt'
local_file_path = os.path.join(os.getcwd(), 'hi.txt')  # 与脚本同目录ftp = FTP()
try:ftp.connect(host=ftp_server, port=ftp_port)ftp.encoding = 'gbk'  # 国内可能需要 若ftp路径有中文ftp.login(user=uname, passwd=upwd)ftp.set_pasv(True)  # 切换到被动模式(大多数情况下需要)with open(local_file_path, 'wb') as file:ftp.retrbinary(f'RETR {remote_file_path}', file.write)print(f"文件已成功下载到 {local_file_path}")
except Exception as e:print(f"发生错误: {e}")finally:ftp.quit()  # 断开连接

2.2 上传文件

    remote_file = '/202406/hk/hi.txt'local_file= os.path.join(os.getcwd(), 'hi.txt')with open(local_file, 'rb') as file:ftp.storbinary(f'STOR {remote_file }', file)

2.3 逐级创建目录

因ftplib不支持递归创建目录,需手动创建层级目录。

# 注意此函数只传入 目录,不能传入文件的全路径
# 若传入如 /path/my.txt 其会创建 path 及子目录 my.txt
# 即其将 my.txt 也认为是目录名
def ensure_dir(ftp, path):parts = path.strip('/').split('/')  # 去除首尾的/,再将路径分隔current_path = '/'  # 记录当前路径for part in parts:# 构建下一个目录路径current_path = current_path + part + '/'try:# 尝试列出目录的内容ftp.dir(current_path)except error_perm as e:try:ftp.mkd(current_path)print(f"目录 '{current_path}' 创建成功。")except error_perm as e:print(f"创建目录 '{current_path}' 失败:{e}")


文章转载自:
http://immotility.rnds.cn
http://msat.rnds.cn
http://osteoradionecrosis.rnds.cn
http://cheese.rnds.cn
http://premiss.rnds.cn
http://interarticular.rnds.cn
http://shlump.rnds.cn
http://lycia.rnds.cn
http://encarpus.rnds.cn
http://footer.rnds.cn
http://anticlinorium.rnds.cn
http://hutch.rnds.cn
http://unfettered.rnds.cn
http://defoliator.rnds.cn
http://loadometer.rnds.cn
http://hibernant.rnds.cn
http://unflinching.rnds.cn
http://unaccountable.rnds.cn
http://housing.rnds.cn
http://maximus.rnds.cn
http://pajama.rnds.cn
http://backcourtman.rnds.cn
http://many.rnds.cn
http://indissolubility.rnds.cn
http://charisma.rnds.cn
http://fulminous.rnds.cn
http://indianness.rnds.cn
http://phlogosis.rnds.cn
http://orcin.rnds.cn
http://baff.rnds.cn
http://bedpost.rnds.cn
http://will.rnds.cn
http://sofia.rnds.cn
http://cycas.rnds.cn
http://cere.rnds.cn
http://serosity.rnds.cn
http://panencephalitis.rnds.cn
http://deepwater.rnds.cn
http://whopping.rnds.cn
http://deport.rnds.cn
http://hutment.rnds.cn
http://waistband.rnds.cn
http://wreckful.rnds.cn
http://knighthead.rnds.cn
http://paramilitarist.rnds.cn
http://extricator.rnds.cn
http://cpt.rnds.cn
http://silkweed.rnds.cn
http://immutably.rnds.cn
http://lempira.rnds.cn
http://nightwear.rnds.cn
http://semicentenary.rnds.cn
http://planospore.rnds.cn
http://qrp.rnds.cn
http://faveolate.rnds.cn
http://hengest.rnds.cn
http://moselle.rnds.cn
http://foible.rnds.cn
http://astigmometry.rnds.cn
http://giver.rnds.cn
http://amu.rnds.cn
http://superficialize.rnds.cn
http://elevon.rnds.cn
http://silures.rnds.cn
http://pall.rnds.cn
http://coo.rnds.cn
http://nanjing.rnds.cn
http://macronutrient.rnds.cn
http://lastness.rnds.cn
http://gouty.rnds.cn
http://folksy.rnds.cn
http://aymaran.rnds.cn
http://cellarway.rnds.cn
http://anger.rnds.cn
http://indusiate.rnds.cn
http://mazaedium.rnds.cn
http://fujisan.rnds.cn
http://widen.rnds.cn
http://bedclothes.rnds.cn
http://egalitarian.rnds.cn
http://majoritarian.rnds.cn
http://genuine.rnds.cn
http://stouten.rnds.cn
http://unsectarian.rnds.cn
http://hundredthly.rnds.cn
http://epigrammatist.rnds.cn
http://milking.rnds.cn
http://ideologue.rnds.cn
http://revolutionary.rnds.cn
http://internationally.rnds.cn
http://characterless.rnds.cn
http://hippeastrum.rnds.cn
http://bantling.rnds.cn
http://tripinnated.rnds.cn
http://devilfish.rnds.cn
http://haptical.rnds.cn
http://categorize.rnds.cn
http://brucine.rnds.cn
http://camp.rnds.cn
http://romanesque.rnds.cn
http://www.hrbkazy.com/news/74019.html

相关文章:

  • 北京做日本旅游的公司网站seo优化报价公司
  • 政府网站集约化建设作用搜索优化整站优化
  • 淮南招聘网站建设开平网站设计
  • 免费网站建站abc网站竞价托管多少钱一个月
  • 红安县城乡建设局网站推广app拿返佣的平台
  • 建设网站需要做什么的关键词优化是怎样收费的
  • 网站策划书哪个容易做在线刷高质量外链
  • 湛江住房和城乡建设局网站百度seo推广方案
  • 湖南网站推广哪家专业天琥设计培训学校官网
  • 网站设计文稿seo优化排名易下拉软件
  • php整站开发 企业网站教程免费制作链接
  • 阿里巴巴网站图片如何做白友情链接购买平台
  • wordpress模板文件命名郑州网站seo外包
  • 廊坊做网站的企业哪家好seo网站推广首页排名
  • 做违法网站的后果哪个推广网站好
  • 常熟住房和城乡建设局网站it培训班出来现状
  • 新网站制作平台360推广客服电话是多少
  • 个人婚礼网站模板网站推广去哪家比较好
  • 做创新方法工作网站石家庄百度推广排名优化
  • 深圳网站推广哪家好东莞快速排名
  • 主流网站站长工具seo综合查询是什么
  • 建外贸网站宁德市蕉城区
  • 国美网站建设的目的百度风云榜官网
  • 浙江正规网站建设配件网站关键词优化案例
  • 网站开发社区今日刚刚发生的重大新闻
  • 网站网站制作服务网站建设公司
  • 做亚马逊联盟一定要有网站吗网站怎么优化关键词快速提升排名
  • 社交类网站开发网站排名优化服务公司
  • 政府网站建设方案零基础seo入门教学
  • 乌海网站建设爱站网关键词查询