[EMAIL PROTECTED] wrote: > Wow, that is fast. Thanks. > >> In your code, you should use string literals like >> >> my_path = r"C:\Programs\Python\new" >> my_path = "C:\\Programs\\Python\\new" >> >> But you said "a program to retrieve the filepath" - and I understand that >> you dont have a string literal, and you compute it somehow. Escape >> characters should not be a problem then. Have you verified the contents >> of the text file? With notepad? > > I meant, I used a GUI-Tkinter Script to retrieve the input(the > directory). my program is supposed to > 1. get the directory from the GUI Script, > with my_path= FieldValue.insert(n, variable.get()) > 2. open a text file > 3. and edit a filepath in the file, > 4 then saving as another new file... > > if that is the case, how should I do, in order to get the input in the > correct format??
The user can input literals like "...\t..." via the GUI, and Python will interpret the sequence "\t" as a backslash followed by the letter t. If you want to allow the user to use forward slashes, too, apply os.path.normpath(): ... os.path.normpath(variable.get()) ... Peter -- http://mail.python.org/mailman/listinfo/python-list