Python : Getting "OverflowError: repeated string is too long" when creating dictionary

Python : Getting "OverflowError: repeated string is too long" when creating dictionary

我正在尝试转换这行代码:

array_of_power1.append(dict(measurement=topic_mqtt_power1,timestamp=int(epoch_time_stamp * 1000000000),fields=dict(power=power1),tags=dict(MachineType=Machine_type,MachineName=Machine_name)))

进入

array_of_power1.append({'measurement' : 'topic_mqtt_power1', 'timestamp' : 'epoch_time_stamp' * 1000000000, fields: {'power' : 'power1'}, tags: {MachineType : Machinetype, MachineName : Machine_name}})

我得到

Traceback (most recent call last): File "", line 1, in OverflowError: repeated string is too long

我从 dict 结构更改为其他方法的原因是 dict 结构 "dict()" 在 micropython 中不起作用。

你应该运行这样来避免OverflowErrorNameError的错误:

array_of_power1.append({'measurement' : 'topic_mqtt_power1', 
                        'timestamp' : 'epoch_time_stamp x 1000000000',
                        'fields': {'power' : 'power1'}, 
                        'tags': {MachineType : Machinetype, MachineName : Machine_name}})