The problem is that your condition if findme in line
does not work with your file. In your file, the string "username" is in the line defining the url -- which is why you're seeing the output that you're seeing.
url=http\://pbx/register?username=E300B1&password=1234&option=localip&localip=
A better approach would be:
def readini(findme):
f = open('/var/tmp/file.ini', "r")
for line in f:
if "=" in line:
key,val = line.split("=",1)
if findme in key:
return val.replace("\\n", "").rstrip()
Using the optional int arg to split guarantees that the list returned has length two and that it will actually be the key,val pair defined by that line.