python 正则求助
有一组 jsonnlist =
{
"activity_icon":"",
"activity_type":"",
"avatar": 626508862403.jpg",
"cover_url":"1626516581.jpg",
"dress":"1",
"hls_url":"https://播放地址/rbzhibo/ddmlhatcur40.m3u8",
"host_intro":"萌新求关照",
"host_uuid":"ddmlhatcur40",
"hot":"48440.25",
"is_follow":"0",
"location":"424",
"nickname":"竹子林_甜甜",
"onlines":"720",
"rank_icon":"",
"rtmp_url":"rtmp://播放地址/rbzhibo/ddmlhatcur40",
"sex_type":"2",
"status":"1",
"stream_id":"z1.rbzhibo.ddmlhatcur40",
"tag":[
],
"title":"",
"tv_room":"0",
"url_out_avatar":"",
"url_out_bg":""
},
{
"activity_icon":"",
"activity_type":"",
"avatar":"/1626172660597.jpg",
"cover_url":"1626091011.jpg",
"dress":"1",
"hls_url":"https://播放地址/rbzhibo/dg9nzqivl4j2.m3u8",
"host_intro":"萌新求关照",
"host_uuid":"dg9nzqivl4j2",
"hot":"11392.5",
"is_follow":"0",
"location":"3134",
"nickname":"时代少女2团",
"onlines":"913",
"rank_icon":"",
"rtmp_url":"rtmp://播放地址/rbzhibo/dg9nzqivl4j2",
"sex_type":"2",
"status":"1",
"stream_id":"z1.rbzhibo.dg9nzqivl4j2",
"tag":[
],
"title":"",
"tv_room":"0",
"url_out_avatar":"",
"url_out_bg":""
},
{
"activity_icon":"",
"activity_type":"",
"avatar":"/taqu_ios_0_1713376644_1627831981901.jpg",
"cover_url":"/taqu_ios_cover_1610177018.jpg",
"dress":"0",
"hls_url":"https://播放地址/rbzhibo/cjvdg367z8bp.m3u8",
"host_intro":"老子可遇不可求🖤",
"host_uuid":"cjvdg367z8bp",
"hot":"10353.5",
"is_follow":"0",
"location":"1644",
"nickname":"趣多多_",
"onlines":"586",
"rank_icon":"",
"rtmp_url":"rtmp://播放地址/rbzhibo/cjvdg367z8bp",
"sex_type":"2",
"status":"1",
"stream_id":"z1.rbzhibo.cjvdg367z8bp",
"tag":[
"嗨唱"
],
"title":"",
"tv_room":"0"
},
# 我想取host_uuid ,hot ,nickname 后面引号里的值
regex = '(?<=host_uuid":").*?"|(?<=nickname":").*?"|(?<=hot":").*?"'
str_select = re.findall(regex, nlist)
但是正则到的结果 后面都有个引号 怎么取消
ddmlhatcur40"
54286.25"
竹子林_甜甜"
dg9nzqivl4j2"
12686.75"
时代少女2团"
bdh5utdwip51"
9678.75"
jsonpath 了解下,json解析用正则不怕麻烦嘛 为啥不用json取呢,可以用jsonpath取,简单多了 json格式都有了...转字典就行了啊,还用正则,不是没事找事么... 楼上都说了。 没毛病 muyan1995 发表于 2021-8-3 09:26
jsonpath 了解下,json解析用正则不怕麻烦嘛
这组数据是josn 的 但是取到的时候 取到的时候是没被格式化的 这是我格式化了方便看 学习fex1111111111111 (?<=host_uuid":").*?(?=")|(?<=nickname":").*?(?=")|(?<=hot":").*?(?=")
Takitooru 发表于 2021-8-3 09:35
(?
原来我后面 忘加括号了 感谢大哥 Takitooru 发表于 2021-8-3 09:35
(?
大佬能能否把调试工具也给一个
页:
[1]
2