I cannot os.chdir(path)
in Python 2.6.5 und开发者_如何学Cer WindowsXP SP2. It works fine under CygWin and MAC OS X, but for WinXP regardless of path
format, I always get this error:
AttributeError: 'str' object has no attribute 'chdir'
.
I thought it was the problem with format of path
but after trying r"C:\WINDOWS"
, 'C:\WINDOWS'
and combinations of \\
, /
or even "\"C:\Windows\""
, I gave up. With formatting I'm using os.path.exists(path)
works perfectly fine...
What I am missing here? What should I be aware of when working with paths consisting of white spaces?
Cheers, Martin
It seems that problem is that in some place you redefine 'os'. Somewhere in your code you do something like this:
import os
os = 'some string'
精彩评论