+ 1
How can i use python to control my computer ?
I mean , if i want to shut down my computer it will show the notepad to save the time in a text
5 odpowiedzi
+ 2
I am not sure I understand the request completely, you want to shutdown your computer and you want to save the date and timestamp of the shutdown to a notepad or some other text editor? If that is the case, you really don't need Python to do that, you can create a batch file, if you're on Windows, that can perform those two tasks. If you're on Linux or Mac a BASh script would work too.
+ 2
If you really wanna use python then I think system function from OS library would be helpful:
import os
command = # something to execute in CMD
os.system(command)
And you can use time/datetime library for time
+ 2
Ok, I would l use the OS library
https://docs.python.org/3/library/os.html
it will allow you to shutdown the machine. I would also use the Logging library
https://docs.python.org/3/howto/logging.html
because it has more control, it is better than just writing to a file. However, if you want to write directly to a file, then
print('YOUR MESSAGE HERE', file='YOUR LOCATION HERE')
should work just fine
+ 1
Thousand thanks😍😍
0
Yeah i mean that ,but i want to chose only python