Python - NT에서 popen 호출하기

  • Post author:
  • Post category:
  • Post comments:0 Comments
  • Post last modified:September 15, 2005

비-유닉스 플랫폼에서 파이썬 사용하기라는 문서는 NT에서 popen 함수를 호출하는 방법에 관해 설명합니다. 그리고 같은 프로그램으로 다른 플랫폼에서 다른 기능들을 사용하는 법에 대해서도 설명합니다. 이 두가지를 모두 응용하면 다음과 같은 코드가 됩니다.


   import sys
   if sys.platform == "win32":
      import win32pipe
      popen = win32pipe.popen
   else:
      import os
      popen = os.popen


   f = popen('dir /c c:\\')
   print f.readlines()
   f.close()

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.