记录变量包含以下数据
[(38177492.733055562,38177482.886388876),(39370533.190833323, 40563588.018611118),(34598340.198888883, 33405299.966944441),(40563586.926666655, 35791393.990277782),(35791394.635833345, 36984434.221388899),(33405296.804722216, 38177491.020277783),(38177487.716111109, 34598350.781944439),(39370531.633888908, 36984439.543333329),(38177489.396111116, 38177487.920833334),(39370529.841666684, 33405297.846666656),(33405301.882777769, 33405297.091944445),(39370533.917222217, 35791396.884444445),(36984443.128055543, 38177492.467500001),(34598343.099166669, 35791389.096111104),(32212259.345555563, 35791393.736388884),(34598345.439444438, 31019213.084444441),(39370531.074722223, 38177482.122222222),(35791401.003333338, 34598351.12555556),(34598344.94194445, 38177486.527500004),(36984439.948888898, 35791396.906944446),(38177487.922499999, 36984440.749722227),(40563581.584166668, 42949669.236111119),(36984437.315277785, 35791396.236388907),(32212259.083611108, 41756619.713333331),(38177489.083888903, 38177494.218888886)]
datalist= defaultdict( list )
datalist['startdate'].append()
datalist['enddate'].append(startDate)
datalist['minute'].append(info[0][2]/60)
datalist['data'].append(records) # look the data part in json
data = simplejson.dumps(datalist, indent=4)
如果我打印数据变量的内容然后将其转换为
{
"startdate": [
"21-02-2011 00:00:00"
],
"enddate": [
"21-02-2011 00:00:00"
],
"minute": [
60
],
"data": [
[ // i want to remove this brack and its matching closing bracket
// but as records is a list so simplejson is converting it into
// sub array in json.
[
38177492.733055562,
38177482.886388876
],
[
39370533.190833323,
40563588.018611118
],
[
34598340.198888883,
33405299.966944441
],
[
40563586.926666655,
35791393.990277782
],
[
35791394.635833345,
36984434.221388899
],
[
33405296.804722216,
38177491.020277783
],
[
38177487.716111109,
34598350.781944439
],
[
39370531.633888908,
36984439.543333329
],
[
38177489.396111116,
38177487.920833334
],
[
39370529.841666684,
33405297.846666656
],
[
33405301.882777769,
33405297.091944445
],
[
39370533.917222217,
35791396.884444445
],
[
36984443.128055543,
38177492.467500001
],
[
34598343.099166669,
35791389.096111104
],
[
32212259.345555563,
35791393.736388884
],
[
34598345.439444438,
31019213.084444441
],
[
39370531.074722223,
38177482.122222222
],
[
35791401.003333338,
34598351.12555556
],
[
34598344.94194445,
38177486.527500004
],
[
36984439.948888898,
35791396.906944446
],
[
38177487.922499999,
36984440.749722227
],
[
40563581.584166668,
42949669.236111119
],
[
36984437.315277785,
35791396.236388907
],
[
32212259.083611108,
41756619.713333331
],
[
38177489.083888903,
38177494.218888886
]
]
]
}
答案 0 :(得分:2)
datalist['data'] = record
有效吗?
答案 1 :(得分:2)
我觉得你真的不需要一个默认的dict,一个普通的dict就可以了。
datalist = {}
datalist['startdate'] = startDate
datalist['enddate'] = endDate