- #!/usr/bin/env python
- #coding=utf-8
- import os,os.path
- import shutil,string
- dir = 'C:\\\\test'
- for i in os.listdir(dir):
- newfile = i.replace('.','_')
- oldfullfile = dir+'\\\\'+i
- newfullfile = dir+'\\\\'+newfile
- print oldfullfile
- print newfullfile
- shutil.move(oldfullfile,newfullfile)
- print i
- #该片段来自于http://www.codesnippet.cn/detail/28112012691.html
来源: http://www.codesnippet.cn/detail/28112012691.html