+ 51
<^>Opening the CMD using Python interpreter <^>
import os os.system( ' start ' ) #type the above code in any python interpreter /IDE of your choice. #hit enter / run. #a command prompt window should show. #works on windows only. #it's such little things that make learning python interesting. #hopefully, this is interesting to someone.
13 Réponses
+ 17
That is so cool!
I started playing with it. It turns out you can run programs with it too.
import os
os.system('start notepad.exe')
opens Notepad
+ 38
@Alper :
thanks for the Additions :
@Ipang:
sounds like you should test out all of your awesome ideas on your own,
when you possibly can :
you'll gain most that way :
when I test them out, I'll let you know though...
~cheers^_^
@Mr. Ashton :
you just made things even more interesting:
one can open any file as long as they know the extension!
Thanks for the Additions!
@Immortal :
anytime...
@Amrit:
thanks for the invite :
but I'll get back to posting codes in a few weeks time :
I have a tone of stalled projects.
@$Vengat:
you do that
@alireza_HDR:
anytime!
@Freetoast:
I'll post more cross-platform ideas when I come across them.
+ 11
That is unfortunate😥. I have an Android.
+ 11
I might try
+ 11
[still playing with it]
It seems you don't even need 'start' - i.e.
import os
os.system('notepad.exe') also opens Notepad
and os.system('cmd') also opens the CMD window
Lots to mess around with!
+ 10
@<^> washika D <^> I'll be looking forward to them!
+ 7
Wow!
+ 7
Nice to see you again!!
+ 5
Amrit Mahendra Joseph cordially invites you to the Greatest Sololearn Coder 3.0 Competition at this link...
https://www.sololearn.com/discuss/556117/?ref=app
+ 5
so cool. Tnx.
+ 5
Hi guys, can somebody enlighten me on these points;
Is it possible for this Python code to be executed on both local and remote machine? if it can be executed on remote then how can we prevent the misuse of it? (prevent people running stuffs)?
Would it give the same result for execution of command line and gui executables?
Does os.system function return any meaningful value? if it does, can we assign it to a variable?
Sorry for many questions, I only have Android.
Thanks,
+ 5
<^> washika D <^>,
Thanks for your response, you're right, I should've at least Google it up anyway. Okay, when I found something I'll post it back here. Best regards,
+ 4
It also works on linux if you use the corresponding commands
For example
os.system('konsole')
Opens Konsole application of KDE