# -*- coding:utf-8 -*-
import os
class ImageRename():
def __init__(self):
self.path = '/home/utry/image_test/'
def rename(self):
filelist = os.listdir(self.path)
total_num = len(filelist)
i = 0
for item in range(299):
i = item + 1
i = bytes(i)
src = self.path + i + '_json/img.png'
dst = self.path + 'train/'+i+'.png'
if os.path.exists(src):
os.rename(src, dst)
print 'converting %s to %s ...' % (src, dst)
src = self.path + i + '_json/label.png'
dst = self.path + 'label/'+i+'_label.png'
if os.path.exists(src):
os.rename(src, dst)
print 'converting %s to %s ...' % (src, dst)
#print 'total %d to rename & converted %d jpgs' % (total_num, i)
if __name__ == '__main__':
newname = ImageRename()
newname.rename()
没了,看这个print 就是python2 python3会报错
网友评论