函数返回多个返回值
def multiple_return_value():
import datetime
d = datetime.date.today()
val_1 = '年份为:{}'.format(d.year)
val_2 = '月份为:{}'.format(d.month)
return val_1, val_2 # 只需在return关键字后跟多个值(依次用逗号分隔)
val = multiple_return_value(); # Python将返回值包装成元组
print(val)
padding_im, draw_img = val
print(padding_im)
print(draw_img)
output
('年份为:2023', '月份为:5')
年份为:2023
月份为:5
标签:年份,return,函数,val,Python,im,print
From: https://www.cnblogs.com/vipsoft/p/17445887.html