1. 读文件方式
第一种 有规律的名称
第二种 无规律的名称
2. 文件名称
用 “{:05d}” 来规范输出数字所占位数,例如:
for i in range(100):
gt_file = 'Reference/' + 'image' + "{:05d}".format(i) + '.jpg'
print(gt_file)
输出:
...
Reference/image00007.jpg
Reference/image00008.jpg
Reference/image00009.jpg
Reference/image00010.jpg
Reference/image00011.jpg
Reference/image00012.jpg
...
3. 存为mat文件
import scipy
from pathlib import Path
save_output = "home/xxx/data/"
path = Path(save_output, "output.mat")
with open(path , 'wb') as output_file:
scipy.io.savemat(
output_file,
{
"prob": pts, # pts 是变量,prob是mat文件中存储pts变量的矩阵名称
"desc": desc
}
)