繁体   English   中英

Python 3.5.2 images2gif类型错误

[英]Python 3.5.2 images2gif type error

我在python3.5.2上使用images2gif时遇到错误。

我已经遇到了一些我找到答案的问题,但没有看到任何地方记录过这个问题。

码:

from PIL import Image
from images2gif import writeGif
import urllib.request

image_files=["list of png image files in the same directory as the script"]

images = [Image.open(fn) for fn in image_files]

gif_file = "test-gif.GIF"
writeGif(gif_file, images, duration=44)

错误:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-19-75192c4aeed1> in <module>()
      7 
      8 gif_file = "test-gif.GIF"
----> 9 writeGif(gif_file, images, duration=44)

C:\Users\mchoy2\AppData\Local\Continuum\Anaconda3\lib\site-packages\images2gif\images2gif.py in writeGif(filename, images, duration, repeat, dither, nq, subRectangles, dispose)
    591     fp = open(filename, 'wb')
    592     try:
--> 593         gifWriter.writeGifToFile(fp, images, duration, loops, xy, dispose)
    594     finally:
    595         fp.close()

C:\Users\mchoy2\AppData\Local\Continuum\Anaconda3\lib\site-packages\images2gif\images2gif.py in writeGifToFile(self, fp, images, durations, loops, xys, disposes)
    446 
    447                 # Write
--> 448                 fp.write(header)
    449                 fp.write(globalPalette)
    450                 fp.write(appext)

TypeError: a bytes-like object is required, not 'str'

编辑:更新时显示完整的错误消息

显示错误消息,因为images2gif是为python 2.x而不是3.x

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM