我需要从多个JPG文件的图像标题信息提取到一个文本或日志文件,但是当我运行下面的代码,我收到一个错误:保存图像头信息到一个文本文件
for root, dirs, filenames in os.walk(topdir):
for f in filenames:
print(topdir)
print(f)
log = open(topdir + f, 'r')
data = p.get_json(log)
formatted_data =((json.dumps(data, sort_keys=True,indent=4, separators=(',', ':'))))
print(data)
print ("There are " + str(len(header_dict)) + " items on the menu.")
我得到当我运行了以下错误:
C:/Users/richie/Desktop/work/imagej/test images and files/XX1
image_D2016-02-03T15-27-56-763207Z_4.jpg
Traceback (most recent call last):
File "C:\Users\richie\Desktop\work\header_dir.py", line 25, in <module>
log = open(topdir + f, 'r')
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/richie/Desktop/work/imagej/test images and files/XX1image_D2016-02- 03T15-27-56-763207Z_4.jpg'
如何打开图像文件,以允许在for循环的功能,对其运行?
日志=打开(TOPDIR + “/” + F, 'R') –