解决方案 python是动态强类型语言,IDE无法判断Image.open("Me.jpg")的返回值类型,无法根据参数类型自动补全
解决:
类型注释:
加上# type: Image.Image就可以了
import torch
from PIL import Image
from torchvision import transforms
img=torch.randn(3,1080,1920)
print(img.shape)
img=transforms.ToPILImage()(img)# type: Image.Image
print(type(img))
img.save('tt.JPG')
网友评论