正则拿id

怎么拿16611138,辅助网站https://regex101.com/

点击查看代码
function save() {
	$.post("single_video_save.jsp", {id:16611138, duration:total, studylong:studylong, position:current}, function(result){
		if (result == "0") {
			studylong = 0;
		}
		if (result == "1") {
			studylong = 0;
			clearInterval(saveHandler);
			player.videoPause();
			alert("当前播放的章节与系统记录的章节不一致,系统只记录最后打开的章节学习时长,请不要打开多个章节同时播放");
			parent.close();
		}
	});
}

点击查看代码
import re

a = """
function save() {
	$.post("single_video_save.jsp", {id:16611138, duration:total, studylong:studylong, position:current}, function(result){
		if (result == "0") {
			studylong = 0;
		}
		if (result == "1") {
			studylong = 0;
			clearInterval(saveHandler);
			player.videoPause();
			alert("当前播放的章节与系统记录的章节不一致,系统只记录最后打开的章节学习时长,请不要打开多个章节同时播放");
			parent.close();
		}
	});
}
"""
print(re.findall(r'{id:(.*?),', a)[0])


posted @ 2024-10-06 23:11  神仙不在  阅读(8)  评论(0)    收藏  举报