python 去掉文件后缀名,python 删除后缀名文件
大家好,又见面了,我是你们的朋友全栈君。
Note:print语句供test 用
#!/usr/bin/python
import os, re, time, sys
import os.path
import string
filter_dir = “/home/fengnazh/splittest/files/”
filterfile_list = os.listdir(filter_dir)
print filterfile_list
file_index = 0
while(file_index < len(filterfile_list)): print file_index tmpf = filter_dir + filterfile_list[file_index] print “000tmpf:” print tmpf if os.path.isfile(tmpf): print “go to if” root, ext = os.path.splitext(filterfile_list[file_index]) print root print ext if ext == ‘.old’: print “before file_index is %s ” % (file_index) print (filterfile_list[file_index]) filterfile_list.remove(filterfile_list[file_index]) #os.remove(os.path.join(tmpf)) file_index = file_index – 1 print “after file_index is %s ” % (file_index) print (filterfile_list[file_index]) print filterfile_list file_index = file_index + 1
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/139557.html原文链接:https://javaforall.cn
相关文章
- python skitlearn_Python sklearn
- python shutil删除_python删除文件
- python 删除文件、目录_python如何删除文件、目录[通俗易懂]
- Python删除文件到回收站
- python删除文件指定行
- python 删除文件中的空行
- python删除行_python 删除文件中指定行
- python删除文件中指定内容
- python判断linux中文件是否存在_Python判断文件是否存在的三种方法
- 【Python】python文件打开方式详解——a、a+、r+、w+、rb、rt区别[通俗易懂]
- python基础系列教程——Python的安装与测试:python解释器、PyDev编辑器、pycharm编译器
- 用Python玩转PDF | 批量加密文件
- 跟我一起学Python从入门到精通《PyInstaller制作可执行exe文件》
- 【说站】python关闭文件的两种方法
- Python修改文件后缀_python重命名文件名
- python读取文件夹下所有图片文件_python删除某一列
- Python文件名后缀_python获取目录下所有文件的文件名
- python读取excel单元格内容_python如何读取文件夹下的所有文件
- python读取excel单元格内容_python如何读取txt文件
- 3招解决python程序输出重定向时的延迟问题
- python自动化测试—Python自动化框架及工具
- python使用opencv如何保存图片_OpenCV Python 保存图片
- windows环境下python清理桌面应用程序进程和删除文件
- Python删除同一个文件夹下的重复文件代码详解编程语言
- python之socket运用之传输大文件详解编程语言
- 轻松实现Linux上Python程序运行(linux执行py文件)
- 如何在Linux中安装Python?(linux安装python)
- Python爬取MySQL数据,助力数据分析(python读取mysql数据)
- Linux系统下安装Python模块指南(linux安装python模块)
- python获取文件列表(或是目录例表)
- 使用go和python递归删除.dsstore文件的方法
- Python删除指定目录下过期文件的2个脚本分享
- Python高级应用实例对比:高效计算大文件中的最长行的长度
- python实现删除文件与目录的方法