Python修改文件扩展名


import os

# 删除原来的csv文件
if os.path.exists('old.csv'):
    print('csv exist')
    os.remove('old.csv')

oldname = 'old.txt'
newname = 'old.csv'

# 将txt文件后缀改为csv
os.rename(oldname, newname)

以上!

原创文章 96 获赞 24 访问量 3万+

猜你喜欢

转载自blog.csdn.net/c2250645962/article/details/105478389