You need to pass a valid variable, you can iterate over the file, so you do not need to use readlines and use with to open your files, since they automatically close them. You also need to print inside the loop if you want to see each line, and str.rstrip() removes the lines from the end of each line:
with open('/home/list.txt') as f: for ip in f: print "https://{0}/result".format(ip.rstrip())
If you want to keep all links, use the list :
with open('/home/list.txt' as f: links = ["https://{0}/result".format(ip.rstrip()) for line in f]
For python 2.6 you need to pass the numerical index of the positional argument, i.e. {0} using str.format .
You can also use names to go to str.format:
with open('/home/list.txt') as f: for ip in f: print "https://{ip}/result".format(ip=ip.rstrip())
source share