用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字

python21    -  云代码空间

——

文件的复制

2021-10-04|266阅||

摘要:#利用闭合函数来完成文件的复制 import os car_python1=r'D:\文档\python1'#源文件的地址 car_python2=r'D:\文档\python2'#复制后的文件的地址 def copy(car_,bas_): filelist=os.listd

#利用闭合函数来完成文件的复制
import os
car_python1=r'D:\文档\python1'#源文件的地址 car_python2=r'D:\文档\python2'#复制后的文件的地址 def copy(car_,bas_):
    filelist=os.listdir(car_) for file in filelist:
        path=os.path.join(car_,file) if os.path.isdir(path):
            copy(path,bas_)#运用了递归函数  pass  else: with open(path,'rb') as strena:
                wen=strena.read()
            path2=os.path.join(bas_,file) with open(path2,'wb') as wstrean:
                rii=wstrean.write(wen) print(rii) else: print('完成复制')

copy(car_python1,car_python2)
顶 1踩 0收藏
文章评论
    发表评论

    个人资料

    • 昵称: python21
    • 等级: 中级程序员
    • 积分: 222
    • 代码: 0 个
    • 文章: 4 篇
    • 随想: 0 条
    • 访问: 5 次
    • 关注

    人气代码

      标签

      最新提问

        站长推荐