Tuesday, August 11, 2020

Python example to read OS info using os.uame()

The function os.uname() returns information identifying the current operating system. The return value is an object with five attributes:

  • sysname - operating system name
  • nodename - name of machine on network (implementation-defined)
  • release - operating system release
  • version - operating system version
  • machine - hardware identifier

example code: sysinfo.py

import os

uname = os.uname()
print(uname)
print("sysname: " + uname.sysname)
print("nodename: " + uname.nodename)
print("release: " + uname.release)
print("version: " + uname.version)
print("machine: " + uname.machine)

Run on Raspberry Pi

No comments: