扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

python什么函数可以返回元组

扬州沐宇科技
2021-02-09 09:36:08
python, 元组

python什么函数可以返回元组

在python中使用format函数返回元祖,具体方法如下:

1.首先,在python中定义一个元组;

def measure():

temp = 39;

wetness = 50

trturn temp,wetness

2.元组定义好后,使用format函数即可返回元组;

def measure():

temp = 39;

wetness = 50

trturn temp,wetness

temp_1,wetenss_1 = measure()

print('temp:{}'.format(temp_1))

print('wetness:{}'.format(wetness_1))

输出结果为:

temp:39

wetness:50

扫码添加客服微信