通过python顺序修改文件名字的方法
作者:longma666666 时间:2023-05-20 08:05:29
问题:将文件夹a下任意命名的10个文件修改为如下图所示文件?
代码:
#coding:utf-8
import os
path = "./a/"
dirs = os.listdir(path)
print type(dirs)
for i in range(0,10):
oldname = path + dirs[i]
newname = path + "%02d"%i +".txt"
os.rename(oldname,newname)
来源:https://blog.csdn.net/longma666666/article/details/79044332
标签:python,文件,名字
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python linecache 处理固定格式文本数据的方法
2022-10-23 21:06:05
浅谈vue获得后台数据无法显示到table上面的坑
2024-05-13 09:07:16
浅谈Python类的单继承相关知识
2023-07-31 15:18:53
Python的五个标准数据类型你认识几个
2022-08-04 15:23:43
![](https://img.aspxhome.com/file/2023/1/65101_0s.png)
解决django 新增加用户信息出现错误的问题
2021-07-27 12:50:46
整理Python中的赋值运算符
2021-10-30 16:25:21
![](https://img.aspxhome.com/file/2023/3/115533_0s.jpg)
python 3.6 +pyMysql 操作mysql数据库(实例讲解)
2024-01-19 16:38:39
![](https://img.aspxhome.com/file/2023/8/79548_0s.png)
PHP中最低级别的错误类型总结
2023-09-04 16:46:17
Python 删除List元素的三种方法remove、pop、del
2021-06-14 20:58:52
Python使用sqlite3模块内置数据库
2024-01-26 21:51:39
![](https://img.aspxhome.com/file/2023/3/79613_0s.png)
Python实现EXCEL表格的排序功能示例
2021-05-17 20:50:11
![](https://img.aspxhome.com/file/2023/7/81727_0s.jpg)
Python使用smtplib 实现单发和群发邮件验证码
2023-07-10 13:56:50
![](https://img.aspxhome.com/file/2023/9/98989_0s.webp)
AI:如何训练机器学习的模型
2023-01-16 13:18:49
![](https://img.aspxhome.com/file/2023/8/81698_0s.png)
Pandas读取并修改excel的示例代码
2022-08-18 23:27:34
![](https://img.aspxhome.com/file/2023/3/66903_0s.png)
MySQL数据库连接异常汇总(值得收藏)
2024-01-22 16:23:55
python用Pygal如何生成漂亮的SVG图像详解
2022-12-12 21:45:22
![](https://img.aspxhome.com/file/2023/3/131593_0s.gif)
ASP中Session技巧 默认过期时间为20分钟
2012-12-04 20:28:26
Python3数据库操作包pymysql的操作方法
2024-01-28 20:01:34
![](https://img.aspxhome.com/file/2023/7/84917_0s.jpg)
vue实现全选、反选功能
2024-04-09 10:58:43
![](https://img.aspxhome.com/file/2023/6/139726_0s.png)
pytorch 数据加载性能对比分析
2022-04-17 04:22:22