python - 批量更改文件名(过滤掉某个字符串)
程序员文章站
2022-03-09 18:08:20
...
import os
path = 'F:\电影\xxx'
drop_str = '【支付宝:xxx 打赏一元 有惊喜哟】'
items = os.listdir(path)
os.chdir(path)
print(os.getcwd())
for name in items:
print(name)
new_name = ''.join(name.split(drop_str))
os.rename(name, new_name)
print('-----------------分界线--------------------')
items = os.listdir(path)
for name in items:
print(name)
上一篇: 用集合去除字符串中重复的值