You can use the psutil library to get the boot time of the system.
Here's an example code snippet:
main.py
import psutil
import datetime
# Get the boot time in seconds since the epochboot_time = psutil.boot_time()
# Convert to a human-readable datetime objectboot_time = datetime.datetime.fromtimestamp(boot_time)
print("System boot time:", boot_time)
250 chars
11 lines
This will output the system boot time in a human-readable format like 2021-10-10 15:30:00.