How do I store all the links into the variable while allowing them to be read separately? (Python) -



How do I store all the links into the variable while allowing them to be read separately? (Python) -

i trying bring in links .txt file , store them in 'link_name'. problem when loop ends, stores lastly link of file in 'link_name'. how store links variable while allowing them read separately? considering list, if that's proper route, unsure how implement it. help can offer.

fr = open('links.txt', 'r') link in fr: link_name = link fr.close() print(link_name)

just append links list.

link_name = [] fr = open('links.txt', 'r') link in fr: link_name.append(link) fr.close() print(link_name)

or

through list comprehension,

link_name = [link link in open('links.txt', 'r')] print(link_name)

python

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -