Python Forum
variables from a text file - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: variables from a text file (/thread-21245.html)



variables from a text file - vlk - Sep-20-2019

hello everyone,
can you please give me the procedure to retrieve the variables from a text file?

exemple :
pin = "all from the first line from /home/me/myvariables.txt"
email = "all from the second line from /home/me/myvariables.txt"

Thank you.


RE: variables from a text file - Yoriz - Sep-20-2019

Forum tutorial on files
Python docs on files


RE: variables from a text file - vlk - Sep-22-2019

thank you,

in this example I can read the second line from my file :

m = open('variables.txt','r')
mail = m.readlines()[1].rstrip()
print("My email : ", mail)
Big Grin