Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python OSError:[Errno 22]和open()试图使用Exifread_Python_Exif - Fatal编程技术网

Python OSError:[Errno 22]和open()试图使用Exifread

Python OSError:[Errno 22]和open()试图使用Exifread,python,exif,Python,Exif,试图从一个图像中提取exif数据。 我不是一个开发人员——我从一个web示例中获得了这段代码。 非常有学问 def process_img(path): f = open('C:\\Users\\evansg\\Desktop\\Photos_for_fun\\PestMonitoring_BTT003_20200527_RCNX1446.jpg/', 'rb') tags = exifread.process_file(f) info = { 'Imag

试图从一个图像中提取exif数据。 我不是一个开发人员——我从一个web示例中获得了这段代码。 非常有学问

def process_img(path):
    f = open('C:\\Users\\evansg\\Desktop\\Photos_for_fun\\PestMonitoring_BTT003_20200527_RCNX1446.jpg/', 'rb')
    tags = exifread.process_file(f)
    info = {
        'Image DateTime': tags.get('Image DateTime', '0'),
        'GPS GPSLatitudeRef': tags.get('GPS GPSLatitudeRef', '0'),
        'GPS GPSLatitude': tags.get('GPS GPSLatitude', '0'),
        'GPS GPSLongitudeRef': tags.get('GPS GPSLongitudeRef', '0'),
        'GPS GPSLongitude': tags.get('GPS GPSLongitude', '0')
    }
    return info

info = process_img('PestMonitoring_BTT021_20200414_RCNX3611.jpg')
print(info)
错误是:


返回包含所需文件的列表。 例如:

此外,我想将其扩展为包括多个文件夹。如蒙指教,不胜感激。 谢谢您的时间。

删除了/escape 文件位于同一文件夹中,因此文件名更易于管理

def process_img(path):
    f = open('C:\\Users\\evansg\\Desktop\\Photos_for_fun\\IMG_0001.JPG', 'rb')
    tags = exifread.process_file(f)
    info = {
        'Image DateTime': tags.get('Image DateTime', '0'),
        
    }
    return info

info = process_img('IMG_0001.JPG')
print(info)
结果:

   [![{'Image DateTime': (0x0132) ASCII=2020:03:27 17:23:42 @ 154}][1]][1]
IMG_0001.JPG
IMG_0251.JPG
IMG_0285.JPG
PestMonitoring_BRT011_20200204_IMG_0124.jpg
PestMonitoring_BRT011_20200329_IMG_0410.jpg
PestMonitoring_BRT011_20200406_IMG_0685.jpg
PestMonitoring_BRT012_20200119_IMG_0031.jpg
PestMonitoring_BRT014_20200221_IMG_0297.jpg
PestMonitoring_BRT014_20200312_IMG_0401.jpg
PestMonitoring_BRT015_20190901_IMG_1340.jpg
PestMonitoring_BRT015_20190929_IMG_8585.jpg
PestMonitoring_BRT016_20190817_IMG_0075.jpg
def process_img(path):
    f = open('C:\\Users\\evansg\\Desktop\\Photos_for_fun\\IMG_0001.JPG', 'rb')
    tags = exifread.process_file(f)
    info = {
        'Image DateTime': tags.get('Image DateTime', '0'),
        
    }
    return info

info = process_img('IMG_0001.JPG')
print(info)
   [![{'Image DateTime': (0x0132) ASCII=2020:03:27 17:23:42 @ 154}][1]][1]