Message245433
On windows, if a Directory/Filename has SPACE, double quotation mark should be used. For example, "R:\just a test\hello.bat" has only one line "@echo hello world", so in the dos prompt
[quote]
R:\just a test>hello.bat
hello world
R:\just a test>cd ..
R:\>set dir1="R:\just a test"
R:\>set dir2=R:\just a test
R:\>%dir1%\hello.bat
hello world
R:\>%dir2%\hello.bat
'R:\just' is not recognized as an internal or external command
[/quote]
Then, in python (it seems to be a common problem in all(?) python version)
[quote]
dir1= os.environ.get('dir1')
print (dir1)
print (os.path.isdir(dir1))
print (os.path.isdir(dir1.replace('"', '')))
print ('*'*10)
dir2= os.environ.get('dir2')
print (dir2)
print (os.path.isdir(dir2))
print (os.path.isdir(dir2.replace('"', '')))
[/quote]
displays
[quote]
"R:\just a test"
False <--obviously, the double quotation marks is treated as the part of the directory name by python, so the answer is wrong
True
**********
R:\just a test
True
True
[/quote]
the patched method is simple
[quote]
if os.name=='nt':
res=res.replace('"', '')
[/quote]
but the not simple thing is that os.py for python 3.4.3 changes a lot than os.py for python 2.7, I get lost while reading os.py for python 3.4.3 by no IDE. So I just report this issue, sorry. |
|
Date |
User |
Action |
Args |
2015-06-17 09:51:02 | 进陆 | set | recipients:
+ 进陆 |
2015-06-17 09:51:02 | 进陆 | set | messageid: <1434534662.14.0.922780196773.issue24461@psf.upfronthosting.co.za> |
2015-06-17 09:51:02 | 进陆 | link | issue24461 messages |
2015-06-17 09:51:01 | 进陆 | create | |
|