Get list of Folders in directory path – Python

Print Directory List in Python To get list of sub-directories present in a computer folder, use the code below. Edit the folder path mentioned in the variable “folder_path”. Then execute this ready to use code. It will print the sub-directories name one by one. #List all subdirectories in a folder […]

How to shutdown a computer using Python?

import os os.system(‘shutdown -s’) This coding for shutdown the computer eventually. After running this code, a message saying “You are about to be signed out in less than a minute” We can avoid that message – os.system(‘shutdown -s -t 0’) instead of using os.system(‘shutdown -s’) will immediately get shut down.

How to get username in Python?

Print Current User Account Name in Python Here is the simple way to get the user name by using python code. Note: It is adviced not to use this function for any authorization purpose as this can be manipulated. Because the getpass reads the data from environment variables (LOGNAME or […]