Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python获取屏幕宽度高度cron_Python - Fatal编程技术网

python获取屏幕宽度高度cron

python获取屏幕宽度高度cron,python,Python,我们应该使用什么工具来获得用户系统屏幕分辨率,比如宽度和高度(以像素为单位) 已尝试: GTK os.popen(“xrandr-q-d:0”).readlines()[0] 两人都有自己的问题 display ":0" 使用其中一个 import ctypes user32 = ctypes.windll.user32 screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1) 或 这两个都是windows的

我们应该使用什么工具来获得用户系统屏幕分辨率,比如宽度和高度(以像素为单位)

已尝试:

  • GTK
  • os.popen(“xrandr-q-d:0”).readlines()[0]
两人都有自己的问题

 display ":0"
使用其中一个

import ctypes
user32 = ctypes.windll.user32
screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)

这两个都是windows的

如果要使用wxPython use(跨平台):

在linux中,您可以使用

import subprocess
output = subprocess.Popen('xrandr | grep "\*" | cut -d" " -f4',shell=True, stdout=subprocess.PIPE).communicate()[0]
print output

希望这对您有所帮助

您正在运行cron作业吗?就是这样,根本没有屏幕可看。crom不连接到X显示器或任何其他pyhonalternative@user2120021我必须承认,我从未使用过cron,但我认为其中一个可以工作,它是基于Unix的吗?
import wx

wx.App(False) # The wx.App object must be created first!    
print wx.GetDisplaySize()
import subprocess
output = subprocess.Popen('xrandr | grep "\*" | cut -d" " -f4',shell=True, stdout=subprocess.PIPE).communicate()[0]
print output