shutil模块(高级的文件copy)
import shutil
import os
f1 = open('本节笔记.txt', encoding = 'utf-8')
f2 = open('笔记2', 'w', encoding = 'utf-8')
1.shutil.copyfileobj(f1, f2) #拷贝文件内容
2.shutil.copyfile('笔记2’, ‘本节笔记‘)
3.shutil.copymode(src, dst) #仅拷贝权限 内容组用户不变
4.shutil.copystat(src, dst) #拷贝状态信息
5.shutil.copy(src, dst) # 拷贝文件和权限
6.shutil.copy2(src, dst) #拷贝文件和状态信息
7.shutil.copytree(src, dst, symlinks = False, ignore = None)
8.shutil.rmtree('test', 'new_test4') #创建目录
9.shutil.rmtree('new_test4') # 删除目录
10. shutil.make_archive('shutil archive test', 'zip', 'H:\phython\老男孩\python 项目实践\第四周\Atm\core') #采用shutil 进行打包压缩
11.import zipfile
z = zipfile.ZipFile('laxi.zip', 'w') #单独压缩文件
z.write(r'a.log’)
z.write(r'data.data')
z.close()
z = zipfile.ZipFile('laxi.zip', 'r') #解压文件
z.extractall()
z.close()
shutil模块(高级的文件copy)的更多相关文章
- shutil 模块 高级的文件、文件夹、压缩包 处理模块
高级的文件.文件夹.压缩包 处理模块 # 将文件内容拷贝到另一个文件中 shutil.copyfileobj(fsrc, fdst[, length]) import shutil shutil.co ...
- shutil模块——高级的文件、文件夹、压缩包处理模块
将文件内容拷贝到另一个文件 shutil.copyfileobj('fsrc', 'fdst', 'length') 方法源码: def copyfileobj(fsrc, fdst, length= ...
- python shutil 模块 的剪切文件函数 shutil.movemove(src, dst),换用 os.rename(sourceFile, targetFile)
Google 一搜python 剪切文件,出来shutil 这模块,网上很多人也跟疯说shutil.move(src, dst)就是用来剪切文件的,结果一试,剪切毛线,文件都复制到另一个文件夹了,源文 ...
- shutil模块(高级的文件、文件夹、压缩包处理模块)
shutil 模块 高级的 文件.文件夹.压缩包 处理模块 shutil.copyfileobj(fsrc, fdst[, length])将文件内容拷贝到另一个文件中 import shutil s ...
- python------模块定义、导入、优化 ------->sys模块,shutil模块
1.sys模块 import sys sys.argv #命令行参数List,第一个元素是程序本身路径sys.exit(n) #退出程序,正常退出时exit(0).sys.version #获取Pyt ...
- 11 python shutil 模块
shutil 模块 高级的 文件.文件夹.压缩包 处理模块 1.将文件内容拷贝到另一个文件中 import shutil f1 = open('os_模块.py','r',encoding='ut ...
- Python入门-模块2(sys模块、shutil 模块)
sys模块: sys.argv 命令行参数List,第一个元素是程序本身路径 sys.exit(n) 退出程序,正常退出时exit(0) sys.version 获取Python解释程序的版本信息 s ...
- day5模块学习--shutil模块
shutil模块 高级的 文件.文件夹.压缩包 处理模块 os模块提供了对目录或者文件的新建/删除/查看文件属性,还提供了对文件以及目录的路径操作.比如说:绝对路径,父目录…… 但是,os文件的操作 ...
- 包与time,datetime,random,sys,shutil 模块
一.包 包是什么? 包是一种通过使用‘.模块名’来组织python模块名称空间的方式. 注意: 1. 在python3中,即使包下没有__init__.py文件,import 包仍然不会报错,而在py ...
随机推荐
- sdut2165 Crack Mathmen (山东省第二届ACM省赛)
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/svitter/article/details/24270265 本文出自:http://blog.c ...
- RabbitMQ负载均衡方案之LVS
负载均衡的方案有很多,适合RabbitMQ使用的处理HAProxy之外还有LVS.LVS是Linux Virtual Server的简称,也就是Linux虚拟服务器, 是一个由章文嵩博士发起的自由软件 ...
- putty SSH tunnel function
github & dynamic
- 51nod 1965 奇怪的式子——min_25筛
题目:http://www.51nod.com/Challenge/Problem.html#!#problemId=1965 考虑 \( \prod_{i=1}^{n}\sigma_0^i \) \ ...
- 使用PHP简单操作Memcached
记得一定要先启动Memcached哦! [root@localhost ~]# /usr/bin/memcached -d -l -m -u root -d 守护进程模式(退出终端窗口之后使程序还在运 ...
- jquery tmpl学习资料 --{{each}} each使用
<!DOCTYPE html><html><head> <script src="Scripts/jquery-1.6.2.min.js&qu ...
- MySqli 中预处理类 stmt
非select 语句(没有结果集的) 1.建立连接数据库 $mysqli=new mysqli("localhost","root","", ...
- 豆瓣源安装python包
例如安装scrapy: pip install -i https://pypi.douban.com/simple/ scrapy
- ghost系统下,C#获取时间带星期几的解决办法
cmd regedit打开注册表,进入到[HKEY_USERS\.DEFAULT\Control Panel\International] ,然后1.将键 sDate 的值由 / 改为 - 2. ...
- springMVC学习(12)-使用拦截器
一.拦截器配置和测试: 1)定义两个拦截器,(要实现HandlerInterceptor接口) HandlerInterceptor1: package com.cy.interceptor; imp ...