python中怎么在list中初始化一系列的相同类的对象
1个回答
展开全部
产生一个燃悔简递增的list:
num_inc_list = range(30)
#will return a list [0,1,2,...,29]1212
产生一前扮个皮裤固定初始值的list:
initial_value = 0
list_length = 5
sample_list = [ initial_value for i in range(10)]
sample_list = [initial_value]*list_length
# sample_list ==[0,0,0,0,0]
num_inc_list = range(30)
#will return a list [0,1,2,...,29]1212
产生一前扮个皮裤固定初始值的list:
initial_value = 0
list_length = 5
sample_list = [ initial_value for i in range(10)]
sample_list = [initial_value]*list_length
# sample_list ==[0,0,0,0,0]
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询