Davidham3
这里可以使用匿名函数lambdaf = lambda x : tuple([0 for i in range(x)])
print(f(100))
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)[0 for i in range(100)]是列表生成式,可以直接生成一个含有100个0的列表,用tuple()强制类型转换为元组lambda是匿名函数,传入参数x,返回冒号后面的内容,所以函数f就是返回包含x个0的元组。