问题
突然出现了一个让人蒙逼的错误
trainval = open(os.path.join(txtsavepath, '/trainval.txt'), 'w')
好好的一段代码,就是报错:
Traceback (most recent call last):
File "/home/zh/local/flowChart/codes/ocr_s.py", line 95, in <module>
test_ss(xmlfilepath, txtsavepath)
File "/home/zh/local/flowChart/codes/ocr_s.py", line 68, in test_ss
ftrainval = open(os.path.join(txtsavepath, '/trainval.txt'), 'w')
PermissionError: [Errno 13] Permission denied: '/trainval.txt'
解决:
探索
print(txtsavepath)
print(os.path.join(txtsavepath, 'trainval.txt'))
print(os.path.join(txtsavepath, '/trainval.txt'))
这个三个分别输出:
/home/zh/local/ocr/VOC2007/ImageSets/Main/
/home/zh/local/ocr/VOC2007/ImageSets/Main/trainval.txt
/trainval.txt
解决办法:去掉斜杠