This frankly seems like a much better solution:
def get_uptime():
with open('/proc/uptime', 'r') as f:
uptime_seconds = float(f.readline().split()[0])
return uptime_seconds
It also has the added benefit of not requiring any additional modules.
Credits: Source