-4

I was wondering If anyone can help me changing INPUT with a txt file which has more lines, and load each line, instead only one from the INPUT. I want to change x=input('Name:') with opening a txt file and read each line at a time.

The code:

x=input('Name:')
r=requests.get('http://mywebsite.com/a?=*.{}'.format(x))
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Ali Alica
  • 1
  • 2
  • 1
    Does this answer your question? [How to read a text file into a list or an array with Python](https://stackoverflow.com/questions/14676265/how-to-read-a-text-file-into-a-list-or-an-array-with-python) – fsimonjetz May 04 '22 at 08:05

1 Answers1

0

Use fhand = open("filename.txt, 'r') to read in the file and loop over the lines of that file using a for loop. Like this:

for line in fhand:
    r=requests.get('http://mywebsite.com/a?=*.{}'.format(line))
TechDash
  • 7
  • 3
  • 8