How to use subprocess.Popen with built-in command on Windows
问题 In my old python script, I use the following code to show the result for Windows cmd command: print(os.popen("dir c:\\").read()) As the python 2.7 document said os.popen is obsolete and subprocess is recommended. I follow the documentation as: result = subprocess.Popen("dir c:\\").stdout And I got error message: WindowsError: [Error 2] The system cannot find the file specified Can you tell me the correct way to use the subprocess module? 回答1: You should use call subprocess.Popen with shell