import subprocess def get_screen_resolution(): output = subprocess.Popen('xrandr | grep "\*" | cut -d" " -f4',shell=True, stdout=subprocess.PIPE).communicate()[0] resolution = output.split()[0].split(b'x') return {'width': resolution[0], 'height': resolution[1]} print(get_screen_resolution()) The resolution[0] would be Byte format like b'1020'. To convert this to Integer format, please try int(resolution[0].decode('UTF-8')).