Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Label.image显示AttributeError:&x27;非类型';对象没有属性';图像';_Python_Label - Fatal编程技术网

Python Label.image显示AttributeError:&x27;非类型';对象没有属性';图像';

Python Label.image显示AttributeError:&x27;非类型';对象没有属性';图像';,python,label,Python,Label,我一直在尝试使用以下代码在标签上显示图像: 范围(0,10)内的i的: img=Image.open(“Toy Story.PNG”) img.load() img=img.resize((100100),Image.ANTIALIAS) img_title=ImageTk.PhotoImage(img) 打印(img_标题) myLabel\u图像=标签(标签,高度=90,宽度=90,图像=img\u标题)。位置(x=108,y=200) myLabel_image.image=img_tit

我一直在尝试使用以下代码在标签上显示图像:

范围(0,10)内的i的
:
img=Image.open(“Toy Story.PNG”)
img.load()
img=img.resize((100100),Image.ANTIALIAS)
img_title=ImageTk.PhotoImage(img)
打印(img_标题)
myLabel\u图像=标签(标签,高度=90,宽度=90,图像=img\u标题)。位置(x=108,y=200)
myLabel_image.image=img_title#用于创建引用

最后一行没有给出属性错误,当我删除最后一行时,图像消失。

尝试将最后两行更改为:

myLabel_image = Label(tab_recommend, height = 90, width = 90, image = img_title)
myLabel_image.place(x=108,y=200)
myLabel_image.image = img_title

place
方法不返回标签,但在适当位置修改标签,返回
None

如果答案有用并解决了问题,请将其标记为已接受。