我试图显示正则表达式中的一组数据,而不是对其进行绘图。我使用此功能来显示我的数据
def loadInfoFrom_Node_Own_Synchronization_signals_List(logFile, signal_sync):
fsrc = open(logFile, 'r')
buff = fsrc.read()
fsrc.close()
list_info = re.findall(signal_sync, buff)
print('list_info= '+str(list_info))
print('list_info_length= '+str(len(list_info)))
dict_node_info = {}
init_time = None
for timestamp, id_src_node, Counter in list_info:
if init_time == None:
init_time = float(timestamp)
if id_src_node not in dict_node_info:
dict_node_info[id_src_node] = {"timestamp": [float(timestamp) - init_time],
'Counter': [int(Counter)]}
else:
dict_node_info[id_src_node]["timestamp"].append(float(timestamp) - init_time)
dict_node_info[id_src_node]["Counter"].append(int(Counter))
return dict_node_info
正则表达式结果集如下:
list_info= [('1547226386', '02141592cc00000001', '1'), ('1547226386', '02141592cc00000001', '2'), ('1547226387', '02141592cc00000001', '3'), ('1547226388', '02141592cc00000001', '4'), ('1547226388', '02141592cc00000001', '5'), ('1547226390', '02141592cc00000001', '6'), ('1547226392', '02141592cc00000004', '7'), ('1547226392', '02141592cc00000001', '8'), ('1547226393', '02141592cc00000004', '9'), ('1547226393', '02141592cc00000001', '10'), ('1547226394', '02141592cc00000001', '11'), ('1547226395', '02141592cc00000001', '12'), ('1547226395', '02141592cc00000001', '13'), ('1547226397', '02141592cc00000001', '14'), ('1547226398', '02141592cc00000001', '15'), ('1547226398', '02141592cc00000004', '16'), ('1547226399', '02141592cc00000004', '17'), ('1547226399', '02141592cc00000001', '18'), ('1547226400', '02141592cc00000004', '19')]
但是,我的函数的结果仅返回该结果
dict_node_info= {'02141592cc00000001': {'Counter': [1], 'timestamp': [0.0]}}
因此,我有一个空图;需要绘制正则表达式的所有输出的时间。
答案 0 :(得分:1)
return dict_node_info
语句向右缩进太远,使函数在第一次迭代后返回-可能不是您想要的。将语句缩进左侧,看看是否有帮助。