Get a unique computer ID in Python on windows and linux

前端 未结 12 967
野趣味
野趣味 2020-11-29 02:27

I\'d like to get an id unique to a computer with Python on Windows and Linux. It could be the CPU ID, the motherboard serial, ... or anything else.

I looked at sever

12条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 02:47

    Invoke one of these in the shell or through a pipe in Python to get the hardware serial number of Apple machines running OS X >= 10.5:

    /usr/sbin/system_profiler SPHardwareDataType | fgrep 'Serial' | awk '{print $NF}'

    or

    ioreg -l | awk '/IOPlatformSerialNumber/ { print $4 }' | sed s/\"//g

    BTW: MAC addresses are not a good idea: there can be >1 network cards in a machine, and MAC addresses can be spoofed.

提交回复
热议问题