我正试图从我的 Image . 首先,我做到了:
Image
from PIL import Image image = Image.open ('C:\Users\yujin\Desktop\ì ì§ ë¶ë\1502635829917s')
这个 output 是我的 形象 . 接下来,我做了:
形象
exif_data = image._getexif() import PIL.ExifTags exif = { PIL.ExifTags.TAGS[k]:v for k, v in image._getexif().items() if k in PIL.ExifTags.TAGS } print exif['GPSInfo']
AttributeError Traceback (most recent call last) <ipython-input-4-d491fd7796a9> in <module>() ----> 1 exif_data = image._getexif() 2 3 import PIL.ExifTags 4 exif = { 5 PIL.ExifTags.TAGS[k]:v AttributeError:“function”对象没有属性“\u getexif”
AttributeError Traceback (most recent call last) <ipython-input-4-d491fd7796a9> in <module>() ----> 1 exif_data = image._getexif() 2 3 import PIL.ExifTags 4 exif = { 5 PIL.ExifTags.TAGS[k]:v
AttributeError:“function”对象没有属性“\u getexif”
我不知道我哪里做错了。
很抱歉我一开始对这个网站的规则一无所知。我不知道如何格式化这个页面上的代码。我道歉!
image = Image.open('C:\Users\yujin\Desktop\ì ì§ ë¶ë\1502635829917s')
然后我发现了一个新错误:
IOError Traceback <ipython-input-17-1d98beb4f253> in <module>() 1 from PIL import Image ----> 2 image = Image.open('C:\Users\yujin\Desktop\Happy\2017-06-06-12-24-45ââ') C:\ProgramData\Anaconda2\lib\site-packages\PIL\Image.pyc in open(fp, mode) 2475 2476 if filename: -> 2477 fp = builtins.open(filename, "rb") 2478 exclusive_fp = True 2479 IOError:[Errno 22]模式(“rb”)或文件名无效:“C:\Users\yujin\Desktop\Happy\x817-06-06-12-24-45”
IOError Traceback <ipython-input-17-1d98beb4f253> in <module>() 1 from PIL import Image ----> 2 image = Image.open('C:\Users\yujin\Desktop\Happy\2017-06-06-12-24-45ââ') C:\ProgramData\Anaconda2\lib\site-packages\PIL\Image.pyc in open(fp, mode) 2475 2476 if filename: -> 2477 fp = builtins.open(filename, "rb") 2478 exclusive_fp = True 2479
IOError:[Errno 22]模式(“rb”)或文件名无效:“C:\Users\yujin\Desktop\Happy\x817-06-06-12-24-45”
这必须在一行上:
image = Image.open('C:\Users\yujin\Desktop\x.JPG')
现在发生的是 image 定义为 Image.open 你只是在评估 ('C:\Users\yujin\Desktop\x.JPG') 在另一行,所以你把字符串放回 Out[10] .
image
Image.open
('C:\Users\yujin\Desktop\x.JPG')
Out[10]
显然 open 函数将不具有该属性 _getexif ,所以你明白了 AttributeError .
open
_getexif
AttributeError