re.findall
参考:https://pythonexamples.org/python-regex-extract-find-all-the-numbers-in-string/
查找字符串中的所有数字
要搜索的字符串
ss = '''var __INLINE_SCRIPT__=function(){"use strict";var e=function(e,t,n,i){var _=new Date(1e3*(1*t)),o=function(e){return"0".concat(e).slice(-2)},r=_.getFullYear()+"-"+o(_.getMonth()+1)+"-"+o(_.getDate())+" "+o(_.getHours())+":"+o(_.getMinutes());i&&(i.innerText=r)};if(!window.__second_open__){e(0,"1616113200",0,document.getElementById("publish_time")),window.__setPubTime=e}return e}();'''
正则代码
matchObj = re.findall(r'[0-9]+', ss)
print(matchObj)
运行结果
['1', '3', '1', '0', '2', '1', '0', '1616113200', '0']