0
私がpython2からpython3に変換しようとしているプログラムは、PIL
のpython画像ライブラリを使用しています。python2 PILをpython3コードに変換する
ウェブからサムネイルをダウンロードして、tkinterスタイルgui内に表示しようとしました。ここでは、私が何を考え、コードの問題の行です:
# grab the thumbnail jpg.
req = requests.get(video.thumb)
photo = ImageTk.PhotoImage(Image.open(StringIO(req.content)))
# now this is in PhotoImage format can be displayed by Tk.
plabel = tk.Label(tf, image=photo)
plabel.image = photo
plabel.grid(row=0, column=2)
プログラムは例外TypeErrorを停止しています、ここbacktrceは次のとおりです。
Traceback (most recent call last): File "/home/kreator/.local/bin/url-launcher.py", line 281, in <module>
main()
File "/home/kreator/.local/bin/url-launcher.py", line 251, in main
runYoutubeDownloader()
File "/home/kreator/.local/bin/url-launcher.py", line 210, in runYoutubeDownloader
photo = ImageTk.PhotoImage(Image.open(StringIO(req.content)))
TypeError: initial_value must be str or None, not bytes
私はここのpython3の要件を満たすにはどうすればよいですか?
可能な複製http://stackoverflow.com/questions/31064981/python3-error-initial-value-must-be-str-or-none – ymonad