Create A List Out Of File Contents With Item Per Line In Python
The aim of this playbook🏁 is to extract list of clients I need to upgrade from
clients.txt file — as a part of the script that changes the version of the component within Consul.
with open("clients.txt", mode="rt", encoding="utf-8") as client_file:
return [line.strip() for line in client_file.readlines()]
- 2 new string-object methods to memorize
<file>.readlines()reads lines from a file and passes them into a list
<str>.string()strips the string from special character such as