chdir()

Basilisk96 basilisk96 at gmail.com
Tue May 8 16:03:00 EDT 2007


On May 8, 3:54 pm, HMS Surprise <j... at datavoiceint.com> wrote:
> Tried executing os.chdir("c:\twill") from a python Tk shell and got
> the error message:
>
> WindowsError: [Error 123] The filename, directory name, or volume
> label syntax is incorrect: 'c:\twill'.
>
> I have the directory exists as I copied the name from the explorer
> window that was open to it.
>
> What is wrong with the syntax?
>
> thanks,
>
> jh


Use
os.chdir(r"c:\twill")
instead.

The "\t" character is the escape character for a tab. You can avoid
such a faux pas by using the raw string construct of the form r"some
string". Otherwise, any backslashes in in your string will be
interpreted as escape characters.

-Basilisk96




More information about the Python-list mailing list