Python 从响应中提取Ip与端口号
import re
def getIp(s):
return "".join(re.findall(r"\d+\.\d+\.\d+\.\d+\:\d+",s))
if __name__ == '__main__':
s = "is this 10.180.25.174:8080 ip and port 124343"
print("http://" + getIp(s))
打印结果是:
http://10.180.25.174:8080
import re
def getIp(s):
return "".join(re.findall(r"\d+\.\d+\.\d+\.\d+\:\d+",s))
if __name__ == '__main__':
s = "is this 10.180.25.174:8080 ip and port 124343"
print("http://" + getIp(s))
打印结果是:
http://10.180.25.174:8080