如何将一个值附加到许多名称略有不同的列表中;例如。我有一天中的小时数列表:[1,2,3....,24],我有 24 列(表),如果一天中的小时数等于一个值,则该值应该是一,并且在其他每一列中它应该是 cero
`h1 = []
h2 = []
h3 = []
h4 = []
h5 = []
h6 = []
h7 = []
h8 = []
h9 = []
h10 = []
h11 = []
h12 = []
h13 = []
h14 = []
h15 = []
h16 = []
h17 = []
h18 = []
h19 = []
h20 = []
h21 = []
h22 = []
h23 = []
h24 = []
HourTable = []
Hour = 0
for i in range(0,len(dataset)):
Hour = Hora + 1
HourTable.append(Hour)
if Hour % 24 == 0:
Hour = 0
` 基本上我想要类似的东西
for h in range(0,len(dataset)):
if HourTable[h] == 1:
h1.append(1)
for hh in range(2,25):
('h'+str(hh)).append(0) #THIS DOES NOT WORK
它会将值 0 附加到从 2 到 24 的每个表中。
一个人会怎么做呢?
谢谢!
编辑; 我最终想要完成的是拥有一个包含 24 列的数据库,其中每一列由一个“1”组成,其余列为“0”
跃然一笑
小唯快跑啊
相关分类