簡體   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