傲视群熊¥ 发表于 2021-4-6 16:03:00

正则表达式出错

varyzb_ztForce={"summary":{size:94,time:"2021-04-02 15:59:55"},
"column":{stockcode:0,stockname:1,nowPrice:2,priceLimit:3,fcb:4,flb:5,fdMoney:6,firstZtTime:7,lastZtTime:8,opentime:9,zhenfu:10,force : 11},
"Data":[["003040","楚天龙",15.71,10.01,78.85084,0.67514986,8.3145171E8,"09:25:00","09:25:00",0,0.0,100.0]
,["603759","海天股份",25.99,9.99,12.785666,0.1470632,2.9812944E8,"09:30:00","09:30:00",0,0.0,100.0]
,["603112","华翔股份",14.16,10.02,1.2883098,0.14568795,1.0974848E8,"09:30:01","09:30:01",0,0.23,82.7531]
,["002762","金发拉比",6.7,10.02,4.0887628,0.10178148,1.31361312E8,"09:25:00","09:25:00",0,0.0,79.31067]
,["600666","ST瑞德",1.62,5.19,4.0069737,0.008937834,1.1636428E7,"09:25:03","09:25:03",0,0.0,79.02441]
,["000422","",2.52,10.04,0.43096286,0.019339595,4.114908E7,"09:30:00","09:30:00",0,3.06,71.34633]
,["603988","中电电ST宜化",4.26,4.93,3.9004014,0.015745385,6.0220912E7,"09:25:00","09:25:00",0,0.0,78.651405]
,["002348","高乐股份机",20.1,10.02,1.5436631,0.043172646,2.04099552E8,"09:25:03","09:25:03",0,0.0,70.402824]
,["001896","豫能控股",8.49,9.97,1.3245884,0.020488458,2.0014168E8,"09:25:00","09:25:00",0,0.0,69.63606]
,["002580","圣阳股份",6.4,9.97,1.2393966,0.049339764,9.8771104E7,"09:40:09","09:40:09",0,9.62,68.02067]
,["002280","*ST联络",3.15,5.0,0.61264014,0.0044524753,2.4702616E7,"09:25:00","09:25:00",0,0.0,67.14424]
,["000799","酒鬼酒",173.86,10.0,0.6064153,0.007968508,4.5015952E8,"09:25:00","09:25:00",0,0.0,67.12245]
,["002103","广博股份",4.42,9.95,1.4959137,0.09671028,1.54351312E8,"09:56:12","09:56:12",0,12.94,67.11914]
,["003026","中晶科技",80.99,10.0,0.265359,0.04689467,9.476008E7,"09:37:39","09:37:39",0,6.78,66.10806]
,["002219","*ST恒康",2.87,5.13,0.21802466,0.002116687,1.1202585E7,"09:45:21","09:37:48",8,2.56,64.63083]
,["002119","康强电子",10.49,9.96,0.30100045,0.014972615,5.7720552E7,"09:39:51","09:39:51",0,8.7,64.384865]
,["600306","*ST商城",6.81,4.93,0.9226413,0.0043123183,5211448.0,"09:50:19","09:44:52",4,4.93,64.31798]
,["000862","银星能源",5.81,10.04,0.14668424,0.016134674,4.699778E7,"11:09:48","09:25:00",2,3.6,62.947517]
,["600610","ST毅达",6.06,5.03,0.27096376,0.0031002273,8429521.0,"13:14:09","13:14:09",0,4.85,62.875137]
,["002162","悦心健康",6.33,10.09,0.2213226,0.014066997,7.5993792E7,"09:32:09","09:25:00",1,4.7,62.58356]
,["000820","*ST节能",2.07,5.08,0.1823176,0.004189668,2494764.0,"09:42:36","09:32:57",4,4.57,62.274124]
,["002005","ST德豪",1.8,5.26,0.046776198,0.0021961746,6688274.0,"10:39:33","09:25:00",9,3.51,61.968742]
,["002269","美邦服饰",3.1,9.93,0.0977911,0.009534528,7.4262048E7,"10:06:33","10:06:33",0,9.22,61.805584]
,["003039","顺控发展",51.66,10.01,0.14450644,0.0315246,1.0097076E8,"11:29:54","09:41:06",21,5.0,61.602688]
,["002289","ST宇顺",6.58,4.94,0.064416505,0.0017478846,3044566.0,"13:16:45","09:33:15",18,4.47,61.182903]
,["000797","中国武夷",3.32,9.93,0.6637184,0.007665468,3.98687E7,"13:01:33","13:01:33",0,10.6,61.075512]
,["600052","浙江广厦",3.05,10.11,0.5902558,0.015025348,3.868696E7,"10:40:11","10:40:11",0,10.11,60.867687]
,["600766","园城黄金",4.72,10.02,0.47967723,0.045901176,4.8515224E7,"09:55:35","09:55:35",0,9.56,60.466278]
,["002878","元隆雅图",23.52,10.01,0.100355886,0.007059714,3.1237948E7,"13:00:06","13:00:06",0,10.71,60.328857]
,["605208","永茂泰",28.95,9.99,0.16425982,0.046027042,6.2626696E7,"09:41:50","09:32:08",1,7.56,59.312733]
,["605198","德利股份",26.86,9.99,0.10360319,0.025595,1.3749634E7,"09:59:09","09:37:11",11,7.13,59.034008]
,["600702","ST舍得",87.61,5.0,0.06838703,0.0013492851,3.9189268E7,"10:38:47","10:10:47",25,1.8,58.890617]
,["605368","蓝天燃气",18.21,10.03,0.26297104,0.046505526,5.5469696E7,"09:34:56","09:34:56",0,9.97,57.89224]
,["600715","文投控股",2.35,9.81,0.39912173,0.0047991835,2.091915E7,"13:09:07","13:09:07",0,11.21,57.805214]
,["002993","奥海科技",60.31,9.99,0.15167083,0.017807523,4.854352E7,"14:31:24","14:31:24",0,9.21,57.395744]
,["603890","春秋电子",14.39,10.02,0.2681915,0.0076835947,4.2419E7,"13:45:00","13:45:00",0,10.63,57.090332]
,["002995","天地在线",51.94,10.0,0.27430725,0.020191712,1.695841E7,"10:21:09","10:21:09",0,10.89,56.95403]
,["603893","瑞芯微",73.82,10.0,0.058208756,0.0016739361,2.3231154E7,"13:30:35","13:30:35",0,8.69,56.90046]
,["603290","斯达半导",197.41,10.0,0.07931576,0.004107143,6.4020064E7,"14:41:03","14:41:03",0,9.2,56.613693]
,["002618","丹邦科技",4.68,10.12,0.276037,0.013823642,3.5447488E7,"09:51:51","09:51:51",0,11.29,56.53949]
,["600360","华微电子",7.18,9.95,0.09174081,0.0060766353,4.189812E7,"14:36:00","14:36:00",0,9.65,56.29779]
,["600460","士兰微",29.32,10.02,0.06493728,0.0048044426,1.84824976E8,"13:14:53","09:51:07",2,9.46,56.213394]
,["600872","中炬高新",52.89,10.0,0.08570561,0.0011781633,4.9641072E7,"09:53:32","09:33:05",36,4.76,56.102947]
,["600916","中国黄金",19.98,10.02,0.09982061,0.030365,1.0920468E8,"14:07:51","14:07:51",0,10.3,55.850033]
,["002900","哈三联",16.94,10.0,0.07743166,0.011949305,6.4086564E7,"14:49:51","10:47:51",2,10.0,55.834064]
,["600215","*ST经开",6.04,5.04,0.08610869,5.7444465E-4,1613489.4,"10:54:39","10:18:33",14,5.22,55.64396]
,["003015","日久光电",15.66,9.97,0.19874138,0.04033195,4.4382412E7,"13:53:48","13:53:48",0,11.59,55.59907]
,["603555","*ST贵人",2.61,4.82,0.19630061,0.0016944002,2779911.0,"10:18:58","10:08:52",4,6.43,55.541477]
,["000608","阳光股份",4.06,10.03,0.05914392,0.0022134702,6738219.5,"13:07:45","13:07:45",0,15.18,55.42251]
,["601258","ST庞大",1.31,4.8,0.01924529,2.5495663E-4,3415824.8,"14:31:12","10:29:05",85,4.8,55.393726]
,["600365","ST通葡",2.74,4.98,0.13654107,0.0028709276,3146536.5,"10:13:12","10:11:12",2,6.51,54.869766]
,["002147","*ST新光",1.59,5.3,0.07805866,0.002861825,2443512.0,"14:35:42","13:55:33",36,5.96,54.834896]
,["600298","安琪酵母",60.84,10.0,0.029360956,0.0012325138,6.179458E7,"14:08:26","09:53:04",16,5.5,54.79977]
,["002776","柏堡龙",4.11,9.89,0.14083132,0.012753207,2.8199114E7,"11:13:24","11:13:24",0,12.03,54.44208]
,["002684","ST猛狮",2.61,4.82,0.03234505,0.0011117964,1270548.0,"14:32:09","13:17:21",9,6.43,53.89901]
,["002400","省广集团",5.5,10.0,0.14170532,0.01219345,1.12037752E8,"10:12:15","10:12:15",0,12.8,53.67802]
,["600275","ST昌鱼",3.01,4.88,0.054814536,9.291722E-4,1423128.0,"13:17:35","10:20:01",22,6.97,53.58279]
,["605111","新洁能",181.84,10.0,0.058926173,0.01095257,5.0387864E7,"13:43:53","09:41:31",13,7.16,53.484024]
,["603080","新疆火炬",18.39,9.99,0.048334733,0.011127356,2.895544E7,"11:13:58","10:00:46",4,7.12,53.418983]
,["002638","*ST勤上",1.84,5.14,0.011601361,5.702119E-4,1045171.56,"14:52:24","14:07:51",12,6.86,53.258865]
,["002766","ST索菱",4.59,5.03,0.043839686,6.2880735E-4,852822.0,"14:42:36","13:05:51",14,7.32,53.12154]
,["605286","同力日升",33.64,10.01,0.12000133,0.057736143,8.157424E7,"14:53:50","14:53:50",0,13.73,52.570015]
,["605358","立昂微",83.38,10.0,0.09028361,0.015470404,5.2345044E7,"10:16:05","09:45:53",16,8.55,52.430187]
,["002193","如意集团",7.11,10.06,0.16137658,0.010353401,1.9207758E7,"10:06:54","10:04:09",3,14.4,52.265533]
,["000662","天夏退",0.23,9.52,0.14942881,0.006059735,1523328.9,"14:52:48","13:33:39",32,9.52,52.004585]
,["605268","王力安防",16.34,10.03,0.13517034,0.029481687,3.2275962E7,"09:50:01","09:42:37",1,9.7,51.79911]
,["603196","日播时尚",7.82,9.99,0.17049417,0.013728334,2.5765336E7,"10:34:10","10:34:10",0,15.75,51.023582]
,["000928","中钢国际",7.39,9.97,0.036896102,0.0033265695,3.0892172E7,"10:55:06","09:36:21",18,9.52,50.865593]
,["000948","南天信息",10.68,9.99,0.11525754,0.003979092,1.3618068E7,"10:02:54","09:59:00",2,10.4,50.772472]
,["000993","闽东电力",8.24,10.01,0.09949578,0.01393644,5.0499252E7,"13:58:36","13:58:36",0,15.49,50.57464]
,["600379","宝光股份",8.99,10.04,0.14103428,0.011602568,3.44422E7,"10:26:19","10:22:07",2,11.38,50.088356]
,["605151","西上海",21.12,10.0,0.019797415,0.007090582,4992768.0,"13:48:17","10:57:43",13,10.21,50.023426]
,["003000","华文食品",15.79,10.03,0.09367281,0.025187477,1.5912388E7,"11:00:30","10:37:30",6,11.08,49.982666]
,["000620","新华联",2.57,9.83,0.16172278,0.004072236,1.9844854E7,"13:23:48","13:02:00",1,11.97,49.667587]
,["600859","王府井",32.26,9.99,0.07823926,0.0020628665,5.1657936E7,"14:52:42","14:52:33",1,11.22,49.57271]
,["603533","掌阅科技",34.71,10.02,0.037281614,0.0013361597,1.8597618E7,"14:25:11","10:25:19",34,10.84,49.539497]
,["603706","东方环宇",16.93,10.01,0.034793798,0.00523483,5170422.0,"14:18:13","09:35:47",8,11.18,49.19411]
,["003001","中岩大地",46.13,9.99,0.010003563,0.0058254427,6527395.0,"14:52:54","13:32:12",57,15.95,49.17916]
,["002542","中化岩土",3.6,10.09,0.040469673,0.0048104636,2.519028E7,"13:46:51","09:48:39",20,16.51,48.918747]
,["002992","宝明科技",32.49,9.99,0.11329735,0.042940754,4.8132508E7,"10:19:27","09:52:03",5,17.43,48.91768]
,["600509","天富能源",7.84,9.96,0.05682448,0.011041405,9.9672232E7,"11:16:15","09:33:41",39,11.78,48.843452]
,["003036","泰坦股份",18.0,10.02,0.12747985,0.048416574,4.7060912E7,"09:48:57","09:25:00",1,17.91,48.60688]
,["000613","大东海A",4.92,10.07,0.07776664,0.0085199345,1.1187096E7,"13:30:18","13:09:00",14,12.75,48.070267]
,["600416","湘电股份",21.02,9.99,0.071593754,0.001311335,2.6071106E7,"14:50:48","14:39:06",2,12.72,48.002495]
,["300689","澄天伟业",36.98,19.99,0.26130247,0.015844202,2.5012864E7,"09:42:33","09:42:33",0,19.99,47.702248]
,["300931","通用电梯",14.21,20.02,0.15541892,0.06049085,4.89442E7,"10:32:15","10:32:15",0,21.45,45.20419]
,["688368","晶丰明源",228.0,20.0,0.014206985,6.4296875E-4,2251728.0,"14:53:49","14:12:49",11,16.57,43.575287]
,["601113","ST华鼎",3.38,4.97,0.014533455,9.375551E-5,287638.0,"14:56:09","13:06:08",18,5.59,14.555804]
,["000559","万向钱潮",5.21,9.92,0.096510485,0.0016950646,2.4313856E7,"14:56:48","14:27:03",3,10.13,10.84358]
,["603996","*ST中新",2.9,5.07,0.009583904,3.1419285E-4,243890.02,"14:55:18","14:08:17",15,9.78,10.31741]
,["601068","中铝国际",3.94,10.06,0.02080829,0.003945794,4600344.0,"15:00:03","09:37:09",3,11.45,8.777812]
,["300965","N恒宇",128.38,108.0,0.0020272438,0.0011266667,2169622.0,"","",0,15.39,0.0]
,["600983","惠而浦",8.12,10.03,0.019604236,2.8730233E-4,1788024.0,"","",0,9.76,0.0]
,["603693","江苏新能",15.73,10.0,0.15920997,0.012476176,3.7876296E7,"","",0,5.94,0.0]
]};
以上数据是json数据,怎么样才能用正则表达式将Data后面的数据提取出来?

lirenbing01 发表于 2021-4-6 16:18:29

既然是json数据 直接解析json不就好了还用正则干嘛

傲视群熊¥ 发表于 2021-4-6 16:21:04

lirenbing01 发表于 2021-4-6 16:18
既然是json数据 直接解析json不就好了还用正则干嘛

但是我用json解析时它会给我报错:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

lirenbing01 发表于 2021-4-6 16:27:45

傲视群熊¥ 发表于 2021-4-6 16:21
但是我用json解析时它会给我报错:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 ( ...

这里的json不规范 用demjson库的demjson.decode

lirenbing01 发表于 2021-4-6 16:30:21

比如这样子

阿奇_o 发表于 2021-4-6 16:45:55

"Data"前的字符串不规范,不是真正的json格式。
所以,我这样做:
import json
import pandas as pd

j_s = ''
with open("json_data.txt", encoding='utf-8-sig') as f:
    j_s += ''.join(f.readlines())

# print(j_s)

j = '{ "data" : ' + j_s + '}' # 让它成为规范的json格式(字符串)
print(j)
print("\n--------------------------\n")

data = json.loads(j)["data"]
# print(data)
df = pd.DataFrame(data)
print(df)

页: [1]
查看完整版本: 正则表达式出错