I am trying to find a substring within a larger string in python. I am trying to find the text present after the string "Requests per second:" is found. It seems my knowledge of python strings and python in general is lacking.
My error is on the 3rd line of code minusStuffBeforeReqPer = output[reqPerIndx[0], len(output)]
, I get the error that without the [0]
on reqPerIndx I am trying to access a tuple, but with it I get the error that I int object has no attribute __getitem__
. I am trying to find the index of the start of the reqPerStr in the output
string.
The code
#output contains the string reqPerStr.
reqPerStr = "Requests per second:"
reqPerIndx = output.find(reqPerStr)
minusStuffBeforeReqPer = output[reqPerIndx[0], len(output)]
eolIndx = minusStuffBeforeReqPer.find("\n")
semiColIndx = minusStuffBeforeReqPer.find(":")
instanceTestObj.reqPerSec = minusStuffBeforeReqPer[semiColIndx+1, eolIndx]