向test.txt文件中写入0-99并修改文件名

# 向test.txt文件中写入0-99
import os
path = 'home/hdkj/dataset/ImageSets/Main/test.txt'
with open(path, 'w') as f:
    for i in range(100):
        f.write(str(i) + '\n')


# 修改从平台下载的图片文件名称
import os
path = 'home/hdkj/1002/data/'
f = os.listdir(path)
n = 0
for i in f:
    old = path + f[n]
    new = path + str(n) + ".jpg"
    os.renames(old, new)
    n = n + 1

 

你可能感兴趣的:(人工智能)