Pythonos.system() Method
ExampleGet your own Python Server
Find the current date of computer:
#Import os Library
import os
# Print the date
print (os.system('date'))
Try it Yourself »
Definition and Usage
The os.system()
method executes the command (a string) in a subshell.
This method is implemented by calling the Standard C function system() with some limitations
If command generates any output, it is sent to the interpreter standard output stream.The command executed on the respective shell opened by the Operating system.
Syntax
os.system(command)
Parameter Values
Parameter | Description |
---|---|
command | Required. String type that tells which command to execute |
Technical Details
Return Value: | On Unix, the return value is the exit status of the process encoded in the format specified for wait().On Windows, the return value is that returned by the system shell after running command. |
---|---|
Python Version: | pre-2.6 |
More Example
Run the notepad:
#Import os Library
import os
# Run the notepad
print (os.system('notepad'))
Try it Yourself »