0
点赞
收藏
分享

微信扫一扫

Python3 去除当前目录下文件指定后缀名

杰克逊爱学习 2022-02-28 阅读 98

Python3 去除当前目录下文件指定后缀名


import os

for i in os.listdir():
    src = os.getcwd()+'\\'+i
    dst = os.getcwd()+'\\'+i.removesuffix('.txt')
    print("src",src)
    print("dst",dst)
    os.rename(src, dst)
    
```python
举报

相关推荐

0 条评论