태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.


2008/05/15 16:56

파이썬 os.system()에 따옴표가 여러개 들어갈 경우 버그

파이썬 os.system()에 따옴표가 여러개 들어갈 경우 명령어가 정상적으로 실행되지 않는데, 이것은 파이썬의 문제가 아니라 윈도우의 문제이다.

다음과 같이 따옴표를 하나 더 넣으면 해결할 수 있다.

result = os.system('""pythonbugtest.exe" "test"')

인용:
yup, but unfortunately, it's a bug at the windows level, not in Python. from what
I can tell, the problem is that cmd.exe cannot parse the command string it's given
by the C-level system() call.

possible workarounds:

1. get rid of the quotes around the command name:

result = os.system('pythonbugtest.exe "test"')

2. add an extra quote (!) before the quoted command name:

result = os.system('""pythonbugtest.exe" "test"')

3. use os.spawn or the subprocess module instead.
원문: http://www.velocityreviews.com/forums/t350422-bug-in-ossystem.html
Trackback 0 Comment 0