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)
程序停止,并给出了类型错误,这里是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