further understanding
#!/usr/bin/python
#coding=utf-8
l=list() def func(para): if isinstance(para,list): print('para类型为列表。') print('\n') for i in para: if type(i)==int or type(i)==float: l.append(i) else: print('列表中元素i={}不是数字类型。'.format(i)) print('para1返回所有数字类型元素之和:{}'.format(sum(l))) print('\n') if isinstance(para,tuple): print('para类型为元组。') print('\n') num=1 for i in para: if type(i)==int or type(i)==float: num=num*i else: print('元组中元素i={}不是数字类型。'.format(i)) print('para2返回所有数字类型元素之积:{}'.format(num)) para1=['herman','0',0,1,1.5,9] para2=(1,2,'h','iu',8.15) func(para1) func(para2)