How get cpu cpuserial in python? : i write a program in python 3.6.2, i want get  cpuserial.i wrote bellow program :

    def getserial():
      # Extract serial from cpuinfo file
      cpuserial = "0000000000000000"
      try:
        f = open('/proc/cpuinfo','r')
        for line in f:
          if line[0:6]=='Serial':
            cpuserial = line[10:26]
        f.close()
      except:
        cpuserial = "ERROR000000000"
    
      return cpuserial
    print(getserial())
when ran program ,it print ERROR000000000.
How fix it?