问题列表 - 第27850页

按名称杀死进程?

我正试图杀死一个进程(特别是iChat).在命令行中,我使用以下命令:

ps -A | grep iChat 
Run Code Online (Sandbox Code Playgroud)

然后:

kill -9 PID
Run Code Online (Sandbox Code Playgroud)

但是,我不确定如何将这些命令转换为Python.

python kill process

84
推荐指数
6
解决办法
19万
查看次数

javascript - 如何从里面重启一个函数?

如何重新启动从同一函数内部调用它的函数?

javascript function restart

3
推荐指数
1
解决办法
3万
查看次数

Javascript引用内部对象的外部对象

好的,我看到一些Java的参考文献,但不是javascript(希望你知道这完全不同).所以这是特定的代码:

function Sandbox() {
    var args = Array.prototype.slice.call(arguments)
        , callback = args.pop()
        , modules = (args[0] && typeof args[0] === 'string' ? args : args[0])
        , i;

    if (!(this instanceof Sandbox)) {
        return new Sandbox(modules, callback);
    }

    if (!modules || modules[0] === '*') {
        modules = [];
        for (i in Sandbox.modules) {
            if (Sandbox.modules.hasOwnProperty(i)) {
                modules.push(i);
            }
        }
    }

    for (i = 0; i < modules.length; i++) {
        Sandbox.modules[modules[i]](this);
    }

    this.core = {
        'exp': {
            'classParser': function (name) {
                return …
Run Code Online (Sandbox Code Playgroud)

javascript reference object

2
推荐指数
1
解决办法
2184
查看次数

C#.NET如何在WebBrowser控件上显示图像?

如何在C#/。NET的Web浏览器控件上显示图像?我正在做类似的事情

webBrowser1.DocumentText = "<html><head></head><body><img src=imagelocationURL.png/></body></html>"
Run Code Online (Sandbox Code Playgroud)

但图像没有出现。我究竟做错了什么?

.net c# webbrowser-control

5
推荐指数
1
解决办法
6254
查看次数

需要将光标位置设置为contentEditable div的末尾,与选择和范围对象一起发出问题

我暂时忘记了跨浏览器的兼容性,我只想让它工作.我正在做的是尝试修改位于typegreek.com的脚本(你可能不需要知道这个).基本脚本可以在这里找到.基本上它的作用是当你输入字符时,它会将你输入的字符转换成希腊字符并将其打印到屏幕上.我想要做的是让它在contentEditable div上工作(它只适用于Textareas)

我的问题是这个函数:用户键入一个键,它被转换为一个希腊键,然后转到一个函数,它通过一些if进行排序,最后它在哪里可以添加div支持.这是我到目前为止所拥有的,

myField是div,myValue是希腊字符.

//Get selection object...
var userSelection
 if (window.getSelection) {userSelection = window.getSelection();}
 else if (document.selection) {userSelection = document.selection.createRange();}

//Now get the cursor position information...
var startPos = userSelection.anchorOffset;
var endPos = userSelection.focusOffset;
var cursorPos = endPos;

//Needed later when reinserting the cursor...
var rangeObj = userSelection.getRangeAt(0) 
var container = rangeObj.startContainer

//Now take the content from pos 0 -> cursor, add in myValue, then insert everything after myValue to the end of the line.
myField.textContent …
Run Code Online (Sandbox Code Playgroud)

javascript range getselection

5
推荐指数
1
解决办法
7834
查看次数

Android相当于Xcode中的UIWebView

来自iPhone世界......

在Android中,我正在寻找一个类似iPhone UIWebView的控件,它可以显示HTML并让我抓住链接点击并停止导航.我的应用程序在HTML中显示带有href的命令的文本.

android widget

4
推荐指数
1
解决办法
3750
查看次数

如何使用python从路径中分割文件名?

我有一个看起来像这样的文件列表:

输入

/foo/bar/baz/d4dc7c496100e8ce0166e84699b4e267fe652faeb070db18c76669d1c6f69f92.mp4
/foo/baz/bar/60d24a24f19a6b6c1c4734e0f288720c9ce429bc41c2620d32e01e934bfcd344.mp4
/bar/baz/foo/cd53fe086717a9f6fecb1d0567f6d76e93c48d7790c55e83e83dd1c43251e40e.mp4
Run Code Online (Sandbox Code Playgroud)

我想从路径中分割出文件名,同时保留两者.

产量

['/foo/bar/baz/', 'd4dc7c496100e8ce0166e84699b4e267fe652faeb070db18c76669d1c6f69f92.mp4']
['/foo/baz/bar/', '60d24a24f19a6b6c1c4734e0f288720c9ce429bc41c2620d32e01e934bfcd344.mp4']
['/bar/baz/foo', 'd53fe086717a9f6fecb1d0567f6d76e93c48d7790c55e83e83dd1c43251e40e.mp4']
Run Code Online (Sandbox Code Playgroud)

怎么会这样呢?

谢谢!

python regex

2
推荐指数
1
解决办法
4874
查看次数

如何在Python脚本中嵌入AppleScript?

我试图在Apple脚本中嵌入AppleScript.我不想将AppleScript保存为文件,然后将其加载到我的Python脚本中.有没有办法在Apple中将AppleScript作为字符串输入并让Python执行AppleScript?谢谢一堆.

这是我的脚本:import subprocess import re import os

def get_window_title():
    cmd = """osascript<<END
    tell application "System Events"
        set frontApp to name of first application process whose frontmost is true
    end tell
    tell application frontApp
        if the (count of windows) is not 0 then
            set window_name to name of front window
        end if
    end tell
    return window_name
    END"""

    p = subprocess.Popen(cmd, shell=True)
    p.terminate()
    return p

def get_class_name(input_str):
    re_expression = re.compile(r"(\w+)\.java")
    full_match = re_expression.search(input_str)
    class_name = full_match.group(1)
    return class_name

print get_window_title()
Run Code Online (Sandbox Code Playgroud)

python macos applescript

11
推荐指数
3
解决办法
1万
查看次数

Tikz:节点组的水平居中

我需要将图形的每一行与中心对齐.我试图用xshift做到这一点.这里的代码:

    \begin{tikzpicture}[node distance=1.5cm, auto, text centered]
    \tikzstyle{every node}=[draw,ball];
    \begin{scope}[xshift=1.5cm]
        \node (A) {A};
        \node [right of=A] (B) {B};
        \node [right of=B] (C) {C};
        \node [right of=C] (D) {D};
    \end{scope}
    \begin{scope}[yshift=-1.5cm]
        \node (AB) {AB};
        \node [right of=AB] (AC) {AC};
        \node [right of=AC] (AD) {AD};
        \node [right of=AD] (BC) {BC};
        \node [right of=BC] (BD) {BD};
        \node [right of=BD] (CD) {CD};
    \end{scope}
    \begin{scope}[yshift=-3cm,node distance=2cm,xshift=1cm]
        \node (ABC) {ABC};
        \node [right of=ABC] (ABD) {ABD};
        \node [right of=ABD] (ACD) {ACD};
        \node [right of=ACD] (BCD) {BCD};
    \end{scope}
    \begin{scope}[xshift=4cm, …
Run Code Online (Sandbox Code Playgroud)

latex tikz centering pgf

12
推荐指数
1
解决办法
8609
查看次数

为什么需要告诉结构它们有多大?

我注意到在c/c ++中需要告诉很多Win32 API结构有多大.即someStruct.pbFormat = sizeof(SomeStruct)

为什么会这样?它只是出于遗留原因吗?还有什么想法"pb"也代表什么?

编辑:哎呀,是的我的意思是"cbFormat"

c c++ struct sizeof

8
推荐指数
2
解决办法
417
查看次数