def func(param):
if isinstance(param,list):
sum_l = 0
for x in param:
if isinstance(x,int) or isinstance(x,float):
sum_l+=x
return sum_l
elif isinstance(param,tuple):
print('tuple')
square_t=1
for y in param:
if isinstance(y,int) or isinstance(y,float):
print(y)
square_t*=y
return square_t
else:
return None
L=['3',True]
T=('3',True)
num=func(T)
print(num)
会自动把布尔类型转换成1,如何去掉布尔类型
T=('3',True) 中不满足int和float的类型,所以打印了原始定义的square_t=1值,并没有你说的转换