Member Avatar for sravan953

Can anyone teach me how to create a function which when called shuts down the computer, or opens an image or video and so on?

Recommended Answers

All 3 Replies

import sys
sys.system('shutdown -s')

That should shut down your system.

Just a quick note. The above code will work if you change all of the instances of "sys" to "os"

SO it will look like

import os
os.system("shutdown -s")

Hope that helps :)

my bad!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.