方法一
im = 1
iy = 2
print(f"im: {im}, iy: {iy}") #打印出im:1,iy:2
方法二
print("im: {}, iy: {}".format(im, iy)) #打印出im:1,iy:2
#或者
print("im: {0}, iy: {1}".format(im, iy)) #打印出im:1,iy:2
运用在项目里,打印出图像的高度、宽度
from PIL import Image
image_path = r'路径'
image = Image.open(image_path)
im_width, im_height = image.size
print(f'im_w:{im_width},im_h:{im_height}')
print('im_w:{0},im_h:{1}'.format(im_width,im_height))