运维需求:
遍历/backup203下的文件,凡是等于api_go.log.1...api_go.log.22的迁移到/rotate203
#输入23,迁移1-22的api_go.log.1-22
shuzi = int(raw_input("input your want:"))
for parent,dirnames,filenames in os.walk('/backup203'):
print filenames
for index,item in enumerate(filenames):
if filenames[index].startswith('api_go.log.') and int(filenames[index].split('.')[2]) < shuzi:
print filenames[index]
str3 = 'mv'+' '+filenames[index]+' '+'/rotate203'
os.system(str3)
api_go.log.23用.分为3段,每一个都为字符串,最后一个为数字字符串,强转为int型