python重命名文件源码

把写内容过程当中比较重要的内容作个收藏,下面的内容段是关于python重命名文件的内容。python

import os
cur_path = os.getcwd()
lists = os.listdir( cur_path )
for f in lists:
    if f != 'ren.py':
        print cur_path
        cur_file = cur_path + '\' + f
        new_file = cur_file.replace( '副本', '' )
        os.rename(cur_file, new_file)
相关文章
相关标签/搜索