How to write a list to a text file in the correct format
- by lia1000
I've got this piece of code that I want to write the output to a text file but with the correct format i.e. no brackets, single quotes so it appears as a formatted list.
This is the code:
file = open("env5.txt", "w");
for key in os.environ.keys():
env = os.environ[key];
key1 = key;
list = str([key, env]).replace("'","").replace('[]', '');
…