Python遍历文件

Friday, Sep 3, 2021 | 1 minute read | Updated at Friday, Sep 3, 2021

@
Python遍历文件

python 遍历文件

import os

s = os.sep
root = "d:" + s + "ll" + s 

for rt, dirs, files in os.walk(root):
    for f in files:
        fname = os.path.splitext(f)
        new = fname[0] + 'b' + fname[1]
        os.rename(os.path.join(rt,f),os.path.join(rt,new))

© 2016 - 2025 Caisong's Blog

🌱 Powered by Hugo with theme Dream.

About Me

大龄程序员,喜欢折腾各种环境部署、软件应用。

博客记录日常。