How to read a text file from a URL in Python
urllib.request.urlopen(URL) to access the text at the given URL. Iterate through each line of the text and decode the line to a readable format using line.decode("utf-8").
import urllib.request
url = "http://textfiles.com/adventure/advent..."
file = urllib.request.urlopen(url)
for line in file:
decoded_line = line.decode("utf-8").strip()
print(decoded_line)
#python #urllib #file #python3 #pythonprogramming #learnpython #short #youtubeshorts