在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