最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

python相乘

IT圈 admin 0浏览 0评论

python相乘

def product(*x, y=(1,)):#测试product((1,),(1,)),tuple或list不能相乘,怎么解决type(x)的类型为int,而不为tuple# result = 1# if type(x)==list or type(x)==tuple:# for num in x:# result = result * num# else:# result = result * x  # if type(y)==list or type(y)==tuple:# for num in y:# result = result * num# else:# result = result * y# return result

python相乘

def product(*x, y=(1,)):#测试product((1,),(1,)),tuple或list不能相乘,怎么解决type(x)的类型为int,而不为tuple# result = 1# if type(x)==list or type(x)==tuple:# for num in x:# result = result * num# else:# result = result * x  # if type(y)==list or type(y)==tuple:# for num in y:# result = result * num# else:# result = result * y# return result

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论