Im kinda new to python, im trying to the basic task of splitting string data from a file using a double backslash (\\) delimiter. Its failing, so far:
from tkinter import filedialog
import string
import os
#remove previous finalhostlist
try:
os.remove("finalhostlist.txt")
except Exception as e:
print (e)
root = tk.Tk()
root.withdraw()
print ("choose hostname target list")
file_path = filedialog.askopenfilename()
with open("finalhostlist.txt", "wt") as rawhostlist:
with open(file_path, "rt") as finhostlist:
for line in finhostlist:
## rawhostlist.write("\n".join(line.split("\\\\")))
rawhostlist.write(line.replace(r'\\', '\n'))
I need the result to be from e.g.
\\Accounts01\\Accounts02
to
Accounts01
Accounts02
Can someone help me with this? I'm using python 3.
EDIT: All good now, strip("\\") on its own did it for me.
Thanks guys!