废话不多说,直接上code
import os
path = 'F:/dataset'
#
#print(os.listdir(path))
for filename in os.listdir(path):
print(filename)
# filename = r'\slice_0001_266_266_1.50_1.50.npy'
transF = os.path.splitext(filename)
if transF[1] == '.npy':
new_file_name = transF[0] + '.png'
os.chdir(path)
os.rename(filename,new_file_name)