1、修改文件内容并写回原文件
  | 
  | 
2、重命名(移动/剪切)文件或文件夹
  | 
  | 
3、删除文件或文件夹
  | 
  | 
4、检查文件或文件夹是否存在
  | 
  | 
5、如果文件夹不存在则创建
  | 
  | 
6、检测文件夹为空则删除
  | 
  | 
7、从路径中提取文件名和目录名
os.path.dirname(path)从path中提取目录,os.path.basename(path)从path中提取文件名。
os.path.split(path)分割路径成目录(os.path.dirname(path))和文件(os.path.basename(path))。
8、复制文件
shutil.copyfile(src, dst): Copy the contents (no metadata) of the file named src to a file named dst and return dst.
shutil.copy(src, dst): Copies the file src to the file or directory dst.
shutil.copy2(src, dst): Identical to copy() except that copy2() also attempts to preserve all file metadata.
shutil.copyfileobj(fsrc, fdst): Copy the contents of the file-like object fsrc to the file-like object fdst.
9、统计某一文件夹下文件数量
  | 
  | 
如统计文件夹数量,用os.path.isdir(path)做判断语句。
10、递归查找文件
Python 3.5+
从Python 3.5版本起,glob模块支持”**”语法,此时必须设置recursive标志。如果匹配的路径是list,则用glob.glob代替glob.iglob。
Python 2.2 to 3.4
对于老版本从Python 2.2以上的,用os.walk递归遍历目标文件夹,然后用fnmatch.filter匹配简单的通配符表达式。
11、按行读取文件内容到list并去除换行
  | 
  | 
12、检查文件夹下是否有文件
  | 
  |