爲什麼以下函數只運行一次只發送一組數據。我認爲每一個都必須意味着數據集中的每個值。python循環只運行一次
data_checkpoint_size = cclient.samples.list(meter_name ='checkpoint.size')
data_checkpoint_length = cclient.samples.list(meter_name ='checkpoint.length')
data_checkpoint_pause = cclient.samples.list(meter_name ='checkpoint.pause')
def counterVolume(data_checkpoint_size, data_checkpoint_length, data_checkpoint_pause):
for each in data_checkpoint_size:
d = each.counter_volume
for each in data_checkpoint_length:
e = each.counter_volume
for each in data_checkpoint_pause:
f = each.counter_volume
pubnub.publish(channel='channel', message= {'checkpoint_size': d, 'checkpoint_length': e, 'checkpoint_pause': f})
counterVolume(data_checkpoint_size, data_checkpoint_length, data_checkpoint_pause)
而且我只得到以下結果而不是系列數據。 checkpoint_size,checkpoint_length和checkpoint_pause三種不同的米,這些都是
{
checkpoint_length: 75,
checkpoint_size: 5000,
checkpoint_pause: 50
}
嗯,一方面,我們需要看看你是怎麼稱呼它的。 –
你是否在談論'pubnub.publish'只被調用一次?它將會被調用一次,因爲它在循環之外。 –
您的d,e和f通過for循環重新分配。 – ismailsunni