import os
import os.path
rootname = ‘D:\Python\spider3.6‘
rootdir = os.listdir(rootname)
for z in rootdir[1:]:
file_detail= rootname+‘\\‘+z
dir_detail = os.listdir(file_detail)
for i in dir_detail:
file_name = file_detail + ‘\\‘ + i
print(file_detail+‘\\‘+i)
# print(i[21:])
os.rename(file_detail + ‘\\‘ + i,file_detail+‘\\‘+i[21:])
import os
import os.path
rootname = ‘D:\Python\spider3.6‘
rootdir = os.listdir(rootname)
for z in rootdir[1:]:
file_detail= rootname+‘\\‘+z
dir_detail = os.listdir(file_detail)
for i in dir_detail:
h = ‘\\‘
print(file_detail+h+i)
h = str(h)
print(i)
k = i.replace(‘讲‘,‘:‘)
os.rename(file_detail+‘{}‘.format(h)+i,file_detail+‘{}‘.format(h)+k)