python函数入门 发表于 2019-10-23 | 更新于 2023-01-11 递归方式实现阶乘123456def factorial(num) -> int: if num > 1: return num * factorial(num - 1) else: return numprint(factorial(3)) python函数入门例子1234567891011121314def sum(*args) -> int: ''' 文档字符串 sum函数,可以输入不定长度的数字参数,返回int类型 ''' print(args) total = 0 for i in args: total += i print( locals()) return totalls=(1,2,3,4,5)sum(*ls)