Python - How to find UUID of computer and set as variable
<p>I have been looking all over the internet for a way to find a way to get UUID for a computer and set it as a variable in python. </p>

<p>Some of the ways I tried doing didn't work.</p>

<p>Original idea:</p>

<pre><code>import os
x = os.system("wmic diskdrive get serialnumber")
print(x)
</code></pre>

<p>However this does not work, and only returns 0. </p>

<p>I am wondering if their is a way i can find a unique Harddrive ID or any other type of identifier in python. </p>

<p>If the aim is to get the serial number of the HDD, then one can do:</p>

<p>In Linux (replace /dev/sda with the block disk identifier for which you want the info):</p>

<pre><code>&gt;&gt;&gt; import os
&gt;&gt;&gt; os.popen("hdparm -I /dev/sda | grep 'Serial Number'").read().split()[-1]
</code></pre>

<p>In Windows:</p>

<pre><code>&gt;&gt;&gt; import os
&gt;&gt;&gt; os.popen("wmic diskdrive get serialnumber").read().split()[-1]
</code></pre>

python python-3.x hwid