'''
函数中的可变参数
'''
#定义函数
def bmi(*person):
for per in person:
for item in per:
name = item[0]
height = item[1]
weight = item[2]
print('\n' + '='*13 + name + '='*13)
print('身高:' + str(height) + '米 \t 体重:' + str(weight) + '千克')
bmi = weight/(height*height)
print('bmi指数:', bmi)
#调用函数
listw = [['张三',1.75,80],['李四',1.85,90],['王五',1.95,90]]
listm = [('赵六',1.55,50),('二狗',1.77,40)]
bmi(listw)
bmi(listm)
最后的调用函数bmi(listw),不应该是bmi(*listw)吗,表示使用一个已经存在的列表作为可变参数
但如果加上了,就会报错。为什么会这样?
另外listm = [(),(),()]这种格式是什么?列表中包含元组吗?