On the os.system problem

The study encountered a problem
Directly in the windows command line haozipc is possible
But by using os.system python ('haozipc') returns 1
In addition to implement os.system in Python('ping www.baidu.com')The return value is 0

Started by Yehudi at February 06, 2016 - 5:03 AM

Because the HaoZip command is not a standard order

Posted by Yehudi at February 11, 2016 - 5:57 AM

The return of 1 is usually haozipc gives help return value prompt.
Returns the return value 0 is usually performed successfully.
Please confirm the command line below the haozipc Is it right? Appeared a lot of help information, if yes, no problem, the two return values are normal.
Because you are using the Ping... Ping., if normal, will give 0, if there is a problem, the return value will be a corresponding change.

Posted by Ashley at February 19, 2016 - 6:05 AM

Thank you for your enthusiastic response, the command line help information series,

But
>>> os.system('haozipc a -tzip D:\python\backup20131121172247.zip D:\Media\test.txt')
1
>>>
This is not successful


In the command line'haozipc a -tzip D:\python\backup20131121172247.zip D:\Media\test.txt'this is the normal file compression

Posted by Yehudi at March 02, 2016 - 6:08 AM

The return value is not successful in all applications is not consistent.
But there is a common situation is: the successful return of 0, therefore, all return to the non - 0, are up to some extent.
For example: users don't know how to use, give help; Run Abnormal etc.
In short, basically not 0 words, you can think it a problem.

Posted by Ashley at March 15, 2016 - 6:28 AM

Still do not understand, then study

Posted by Yehudi at March 24, 2016 - 6:38 AM

Still do not understand, then study

Posted by Yehudi at March 26, 2016 - 7:00 AM

  1. os.system(r'"C:\Program Files (x86)\Internet Explorer\iexplore.exe" " ;')
'C:\Program' Not the internal or external command, not running program
Or batch file.

Excuse me, why is this wrong

Posted by Boyd at April 02, 2016 - 7:53 AM

In the image of the os.system (" command") output to not command, the return value is command

Windows didn't play, Linux, correct execution command returns a value is generally 0

Posted by Gregary at April 12, 2016 - 7:57 AM

The os.system default to " " (spaces) partition, as the commands and parameters so that the front, it is a command, and not the path.
You can replace the os.system implementation using subprocess module. Or, you can use the following very ugly format to continue using os.system:
os.system('\"\"C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe\"\"')
\"\"In order to ensure Python filtering, can be passed to the windows with a " " long path + enclosed executive program.

Posted by Ashley at April 13, 2016 - 8:00 AM

Slash and space escape, less use of windows

Posted by Lucinda at April 27, 2016 - 8:17 AM

Thank you very much,
Toss about, can perform the following
  1. os.system(r'start "C:\Program Files (x86)\Internet Explorer\iexplore.exe" " ;')

Posted by Boyd at May 05, 2016 - 8:55 AM

The mechanism of windows is very boring, the command line matlab before operation, it should be people tortured to death

Posted by Gavin at May 06, 2016 - 9:31 AM

Now with subprocess, os.system () is almost deserted function

Posted by Judy at May 14, 2016 - 10:12 AM

Thank you so much God enthusiastic reply, because of you, let the world more beautiful

Posted by Yehudi at May 17, 2016 - 10:20 AM