#python #string #list
#python #строка #Список
Вопрос:
s='[{affectedRows:0,data:[{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Morning Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:157193737,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598488770565),TSEND:new Date(1598488883573),DURATION:"000 00:01:53",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Morning Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:157187739,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598486907836),TSEND:new Date(1598486952947),DURATION:"000 00:00:45",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Night Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:157140798,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598457456046),TSEND:new Date(1598457600090),DURATION:"000 00:02:24",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Night Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Night Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:157082517,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598438706011),TSEND:new Date(1598438770312),DURATION:"000 00:01:04",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Night Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Morning Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:157022983,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598418938835),TSEND:new Date(1598419241188),DURATION:"000 00:05:02",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Morning Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:157016784,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598417178457),TSEND:new Date(1598417524244),DURATION:"000 00:05:45",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:1,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Morning Shift",TEXT:"出口闭锁",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:156770882,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"O",ADDRESS:"DB2308.DBX12.1",VARIABLE_NAME:"LF2911:Faults.S02.RB320.OutletBlocked.Value",TSBEGIN:new Date(1598318321801),TSEND:new Date(1598318330198),DURATION:"000 00:00:08",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Morning Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:156770860,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598318305539),TSEND:new Date(1598318311616),DURATION:"000 00:00:06",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Morning Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:156770850,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598318299485),TSEND:new Date(1598318301485),DURATION:"000 00:00:02",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Morning Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:156770208,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598318125586),TSEND:new Date(1598318293513),DURATION:"000 00:02:47",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Morning Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:156755443,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598313672630),TSEND:new Date(1598313820398),DURATION:"000 00:02:27",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Morning Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:156586412,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598245145796),TSEND:new Date(1598245267127),DURATION:"000 00:02:01",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:1,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Morning Shift",TEXT:"出口闭锁",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:156567889,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"O",ADDRESS:"DB2308.DBX12.1",VARIABLE_NAME:"LF2911:Faults.S02.RB320.OutletBlocked.Value",TSBEGIN:new Date(1598239753597),TSEND:new Date(1598239769806),DURATION:"000 00:00:16",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Morning Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:156566901,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598239495914),TSEND:new Date(1598239755589),DURATION:"000 00:04:19",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Morning Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:156552663,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598233968242),TSEND:new Date(1598234023411),DURATION:"000 00:00:55",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Night Shift",TEXT:"位置无效占位",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:156445504,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.2",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidOccupied.Value",TSBEGIN:new Date(1598143424678),TSEND:new Date(1598173427224),DURATION:"000 08:20:02",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Night Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:156350573,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598090562849),TSEND:new Date(1598090745901),DURATION:"000 00:03:03",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Night Shift"},{CONSOLEAREA:"PU011",ACTIVE:false,ISWARNING:0,PLCNAME:"面漆1线",PLC:"LF2911",ESTOPAREA:"B.5",INTERVALEND_ID:"Morning Shift",TEXT:"位置无效自由",DEVICENOTRELEVANT:false,FUNCTIONGROUPDESCRIPTION:"防爆区滚床",RECORDID:156276107,PANELAREA:"S02",FUNCTIONGROUP:"RB320",MESSAGETYPE:"T",ADDRESS:"DB2308.DBX8.3",VARIABLE_NAME:"LF2911:Faults.S02.RB320.InvalidFree.Value",TSBEGIN:new Date(1598067289107),TSEND:new Date(1598067362857),DURATION:"000 00:01:13",MESSAGEGROUP:"FM",INTERVALBEGIN_ID:"Morning Shift"}],endRow:18,invalidateCache:false,isDSResponse:true,operationType:"fetch",queueStatus:0,startRow:0,status:0,totalRows:18}]'
Я ищу в Интернете, поэтому я использовал пакет ast, но они не сработали
s_new=eval(s)
import ast
s_new = ast.literal_eval(s)
как это решить?
Комментарии:
1. Я получил это из веб-ответа, но не могу быть проанализирован. Я не знаю почему.
2. это определенно недопустимый формат JSON. загляните в документы api веб-сайта? если это общедоступно, вы также можете поделиться ссылкой здесь
3. возможно, это недопустимый формат json, я получил его с нашего внутреннего веб-сайта. Я проверил это, это список внутри » »
Ответ №1:
Хорошо, вот простое решение Python, если вы не хотите писать синтаксический анализатор и не хотите использовать javascript.
from datetime import datetime
def date(val):
return datetime.fromtimestamp(val/1000)
s = '... your string ...'
temp = (s.replace('{','dict(').replace('}',')').replace(':','=')
.replace('false','False').replace('true','True').replace('new Date','date'))
result = eval(temp)
Обратите внимание здесь, если вы хотите использовать этот метод, необходимо убедиться, что нет конфликтующих символов, которые будут мешать eval
.
Этот метод основан на некотором наблюдении за вашей исходной строкой:
ключ в них не заключен в кавычки, поэтому, если вы используете dict(KEY=Value)
в python, для этого не требуется заключать ключ в кавычки. Кроме того, даты в строке на самом деле являются javascript
Date
объектами, они представлены во времени эпохи unix, поэтому мне нужно использовать пользовательскую date
функцию, чтобы скрыть эти временные метки в действительный объект python datetime
.
Старый метод javascript:
Если вы используете javascript, это может быть довольно просто:
var s = "... your string here..."
var resu<
eval('result = ' s);
console.log(result)
Затем, если вам нравится использовать python, вы можете сохранить результат в реальной строке JSON.
var result_string = JSON.stringify(result)
Вот результат:
'[{"affectedRows":0,"data":[{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Morning Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":157193737,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-27T00:39:30.565Z","TSEND":"2020-08-27T00:41:23.573Z","DURATION":"000 00:01:53","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Morning Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":157187739,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-27T00:08:27.836Z","TSEND":"2020-08-27T00:09:12.947Z","DURATION":"000 00:00:45","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Night Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":157140798,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-26T15:57:36.046Z","TSEND":"2020-08-26T16:00:00.090Z","DURATION":"000 00:02:24","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Night Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Night Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":157082517,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-26T10:45:06.011Z","TSEND":"2020-08-26T10:46:10.312Z","DURATION":"000 00:01:04","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Night Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Morning Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":157022983,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-26T05:15:38.835Z","TSEND":"2020-08-26T05:20:41.188Z","DURATION":"000 00:05:02","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Morning Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":157016784,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-26T04:46:18.457Z","TSEND":"2020-08-26T04:52:04.244Z","DURATION":"000 00:05:45","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":1,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Morning Shift","TEXT":"出口闭锁","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":156770882,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"O","ADDRESS":"DB2308.DBX12.1","VARIABLE_NAME":"LF2911:Faults.S02.RB320.OutletBlocked.Value","TSBEGIN":"2020-08-25T01:18:41.801Z","TSEND":"2020-08-25T01:18:50.198Z","DURATION":"000 00:00:08","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Morning Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":156770860,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-25T01:18:25.539Z","TSEND":"2020-08-25T01:18:31.616Z","DURATION":"000 00:00:06","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Morning Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":156770850,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-25T01:18:19.485Z","TSEND":"2020-08-25T01:18:21.485Z","DURATION":"000 00:00:02","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Morning Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":156770208,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-25T01:15:25.586Z","TSEND":"2020-08-25T01:18:13.513Z","DURATION":"000 00:02:47","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Morning Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":156755443,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-25T00:01:12.630Z","TSEND":"2020-08-25T00:03:40.398Z","DURATION":"000 00:02:27","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Morning Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":156586412,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-24T04:59:05.796Z","TSEND":"2020-08-24T05:01:07.127Z","DURATION":"000 00:02:01","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":1,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Morning Shift","TEXT":"出口闭锁","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":156567889,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"O","ADDRESS":"DB2308.DBX12.1","VARIABLE_NAME":"LF2911:Faults.S02.RB320.OutletBlocked.Value","TSBEGIN":"2020-08-24T03:29:13.597Z","TSEND":"2020-08-24T03:29:29.806Z","DURATION":"000 00:00:16","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Morning Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":156566901,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-24T03:24:55.914Z","TSEND":"2020-08-24T03:29:15.589Z","DURATION":"000 00:04:19","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Morning Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":156552663,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-24T01:52:48.242Z","TSEND":"2020-08-24T01:53:43.411Z","DURATION":"000 00:00:55","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Night Shift","TEXT":"位置无效占位","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":156445504,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.2","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidOccupied.Value","TSBEGIN":"2020-08-23T00:43:44.678Z","TSEND":"2020-08-23T09:03:47.224Z","DURATION":"000 08:20:02","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Night Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":156350573,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-22T10:02:42.849Z","TSEND":"2020-08-22T10:05:45.901Z","DURATION":"000 00:03:03","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Night Shift"},{"CONSOLEAREA":"PU011","ACTIVE":false,"ISWARNING":0,"PLCNAME":"面漆1线","PLC":"LF2911","ESTOPAREA":"B.5","INTERVALEND_ID":"Morning Shift","TEXT":"位置无效自由","DEVICENOTRELEVANT":false,"FUNCTIONGROUPDESCRIPTION":"防爆区滚床","RECORDID":156276107,"PANELAREA":"S02","FUNCTIONGROUP":"RB320","MESSAGETYPE":"T","ADDRESS":"DB2308.DBX8.3","VARIABLE_NAME":"LF2911:Faults.S02.RB320.InvalidFree.Value","TSBEGIN":"2020-08-22T03:34:49.107Z","TSEND":"2020-08-22T03:36:02.857Z","DURATION":"000 00:01:13","MESSAGEGROUP":"FM","INTERVALBEGIN_ID":"Morning Shift"}],"endRow":18,"invalidateCache":false,"isDSResponse":true,"operationType":"fetch","queueStatus":0,"startRow":0,"status":0,"totalRows":18}]'
Затем вы можете использовать python json
для преобразования в список.
Комментарии:
1. На самом деле это хороший ответ, потому что он переводит OP в место, где они действительно могут обрабатывать эти данные в python.
2. @Zeitlin, это допустимая строка json, поэтому вы можете вызвать
json.loads
ее в python, чтобы получить список.3. OP? что это значит?
4. @Zeitlin OP = Оригинальный плакат = ты 🙂
5. @snakecharmerb Я пробовал
json.loada
, он также показывает некоторые ошибки