我有一个脚本使用java连接到localhost上的端口10.0中显示X11
但我总是得到这个错误
java.lang.InternalError: Can't connect to X11 window server using 'localhost:10.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:62)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:178)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:142)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:82)
at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:112)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at java.awt.Toolkit$2.run(Toolkit.java:849)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:841)
at ij.io.Opener.openJpegOrGif(Opener.java:367)
at ij.io.Opener.openImage(Opener.java:220)
at ij.io.Opener.openImage(Opener.java:249)
at ij.io.Opener.open(Opener.java:116)
at ij.IJ.open(IJ.java:1112)
at ij.macro.Functions.open(Functions.java:2006)
at ij.macro.Functions.doFunction(Functions.java:129)
at ij.macro.Interpreter.doStatement(Interpreter.java:205)
at ij.macro.Interpreter.doBlock(Interpreter.java:515)
at ij.macro.Interpreter.runUserFunction(Interpreter.java:278)
at ij.macro.Interpreter.getFactor(Interpreter.java:1200)
at ij.macro.Interpreter.getTerm(Interpreter.java:1162)
at ij.macro.Interpreter.getExpression(Interpreter.java:1145)
at ij.macro.Interpreter.getBooleanExpression(Interpreter.java:881)
at …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用PIL将照片分成多个部分.
def crop(Path,input,height,width,i,k,x,y,page):
im = Image.open(input)
imgwidth = im.size[0]
imgheight = im.size[1]
for i in range(0,imgheight-height/2,height-2):
print i
for j in range(0,imgwidth-width/2,width-2):
print j
box = (j, i, j+width, i+height)
a = im.crop(box)
a.save(os.path.join(Path,"PNG","%s" % page,"IMG-%s.png" % k))
k +=1
Run Code Online (Sandbox Code Playgroud)
但它似乎没有起作用.它会分割照片但不是精确的方式(你可以尝试).
我有一个包含输入和下拉列表的表单:
[...]
<select>
<option></option>
<option>Test User 1</option>
<option>Test User 2</option>
</select>
[...]
Run Code Online (Sandbox Code Playgroud)
我将值传递给Selenium作为字典:
dict = {'user':'Test User 1', [...]}
Run Code Online (Sandbox Code Playgroud)
我使用for循环来执行此操作:
for key in dict.keys():
inputElement = driver.find_element_by_name(key)
inputElement.clear()
inputElement.send_keys(dict[key])
Run Code Online (Sandbox Code Playgroud)
它适用于所有输入,但使用下拉菜单不起作用.但是当我没有循环的情况下它可以工作.例如:
inputElement = driver.find_element_by_name('user')
inputElement.clear()
inputElement.send_keys(dict['user'])
Run Code Online (Sandbox Code Playgroud)
要么
inputElement = driver.find_element_by_name('user')
inputElement.clear()
inputElement.send_keys('Test User 1')
Run Code Online (Sandbox Code Playgroud) 我刚刚遇到了声称被谷歌 2004 年使用的挑战之一
(the first 10-digit prime in e).com
Run Code Online (Sandbox Code Playgroud)
除此之外,我想接受挑战并用 python 解决它
>>> '%0.52f' % math.exp(1)
'2.71828182845904509079**5598298427**6488423347473144531250'
>>> '%0.52f' % numpy.exp(1)
'2.71828182845904509079**5598298427**6488423347473144531250'
Run Code Online (Sandbox Code Playgroud)
我的程序返回的5598298427是一个素数
上网查了一下,正确答案是7427466391
但是 python 中的 exp 数字不包括上面的数字
import numpy
import math
def prime(a):
if a == 2: return True
if a % 2 == 0: return False
if a < 2: return False
i = 2
n = math.sqrt(a) + 1
while(i < n):
if a % i == 0:
return False
i += 1 …Run Code Online (Sandbox Code Playgroud) 我试图找出是否继承QtConcurrent并在其中编写run方法将起作用:
class Task(QtCore.QtConcurrent):
def run(self, function):
function()
Run Code Online (Sandbox Code Playgroud)
还是完全没用?
我有一个包含许多模块、文件和文件夹的 PySide 项目。我还使用了 Numpy、Matplotlib 和许多其他模块。
我想用 cython 构建这个项目。代码是纯Python,我希望 cython 将所有依赖项添加在一起,就像使用时一样pyinstaller
是否有可能,或者 cython 只是为了编写扩展(dll、so、lib)而设计的?
我试图检查给定的列表是否是另一个列表的子序列:
这里是给出真实的列表的例子:
subseq "" "w"
subseq "w" "w"
subseq "ab" "cab"
subseq "cb" "cab"
subseq "aa" "xaxa"
not (subseq "aa" "xax")
not (subseq "ab" "ba")
Run Code Online (Sandbox Code Playgroud)
我刚刚谈到这个,但在某些情况下,它给出了错误的结果
subseq :: Eq a => [a] -> [a] -> Bool
subseq [] [] = True
subseq [] ys = True
subseq xs [] = False
subseq (x:xs) (y:ys) = x == y || subseq xs ( 1 `drop` ys )
Run Code Online (Sandbox Code Playgroud) 我有一个qtablewidgetitem,里面有一个QCheckbox
当禁用qtablewigetitem如下时
flags = self.item(row+1, self.columns["USER_ACCESS"]).flags()
flags |= QtCore.Qt.ItemIsSelectable
flags |= QtCore.Qt.ItemIsEditable
flags |= QtCore.Qt.ItemIsEnabled
self.item(row+1, self.columns["USER_ACCESS"]).setFlags(flags)
Run Code Online (Sandbox Code Playgroud)
它已被禁用,我无法单击它,但它会显示,因为它仍然处于启用状态。
我想将其显示为灰色
更新:
class CheckBoxDelegate(QtGui.QStyledItemDelegate):
"""
A delegate that places a fully functioning QCheckBox in every
cell of the column to which it's applied
"""
def __init__(self, parent):
QtGui.QStyledItemDelegate.__init__(self, parent)
self.parent = parent
def createEditor(self, parent, option, index):
'''
Important, otherwise an editor is created if the user clicks in this cell.
** Need to hook up a …Run Code Online (Sandbox Code Playgroud) 我写了一个脚本,它备份到已装载的磁盘/mount/data/,我不想复制该文件夹,同时复制其他人,我不想复制proc,sys也
for dir in `ls /`; do
if [ $dir != "mount" -o $dir != "proc" -o $dir != "sys" ]; then
sh /home/bin/safecopy $dir
fi
done
Run Code Online (Sandbox Code Playgroud)
但条件被忽略了
$dir != "mount" -o $dir != "proc" -o $dir != "sys"
Run Code Online (Sandbox Code Playgroud)
和safecopy尝试复制mount,proc并sys...为什么?
但是当我这样做的时候
for dir in `ls /`; do
if [ $dir != "mount" ]; then
if [ $dir != "proc" ]; then
if [ $dir != "sys" …Run Code Online (Sandbox Code Playgroud)