Python Forum
what will be the best way to find data in txt 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: what will be the best way to find data in txt file? (/thread-37810.html)



what will be the best way to find data in txt file? - korenron - Jul-25-2022

Hello,
I have created a "config" file for my code with all kind of data inside , for the code to run and use
the config.txt is :
IP = 10.0.0.5
user = root
pass = MyPass1
FreeData = test
what do I need to do in order to read IP\user\pass\FreeData and use it in the code ?

** will it be better to create a json file? and then get the data from it?

Thanks,


RE: what will be the best way to find data in txt file? - Axel_Erfurt - Jul-25-2022

You can use configparser.

https://docs.python.org/3/library/configparser.html


RE: what will be the best way to find data in txt file? - korenron - Jul-25-2022

Thanks
it's great solution!