小编cgt*_*cgt的帖子

尝试从Go程序中启动外部编辑器

我试图找出如何从Go程序中启动外部编辑器,等待用户关闭编辑器,然后继续执行该程序.根据这个 SO答案,我目前有这个代码:

package main

import (
    "log"
    "os"
    "os/exec"
)

func main() {
    fpath := os.TempDir() + "/thetemporaryfile.txt"
    f, err := os.Create(fpath)
    if err != nil {
        log.Printf("1")
        log.Fatal(err)
    }
    f.Close()

    cmd := exec.Command("vim", fpath)
    err = cmd.Start()
    if err != nil {
        log.Printf("2")
        log.Fatal(err)
    }
    err = cmd.Wait()
    if err != nil {
        log.Printf("Error while editing. Error: %v\n", err)
    } else {
        log.Printf("Successfully edited.")
    }

}
Run Code Online (Sandbox Code Playgroud)

当我运行程序时,我得到了这个:

chris@DPC3:~/code/go/src/launcheditor$ go run launcheditor.go 
2012/08/23 10:50:37 Error while editing. Error: exit …
Run Code Online (Sandbox Code Playgroud)

linux editor go

8
推荐指数
1
解决办法
1955
查看次数

用Pyside做了一个GUI,但我后面还有一个cmd窗口?

可能重复:
如何在Windows上运行的PyQt应用程序中隐藏控制台窗口?

我使用QT Designer和Pyside制作了一个GUI程序,它完全有效.唯一的问题是每当我运行它时,我会在后台获得一个cmd.exe窗口.这很烦人.有没有什么办法解决这一问题?

python user-interface qt cmd pyside

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

为什么我的Python程序的输出看起来很奇怪?

我已经使用Python了一段时间,但在今天之前我从来没有真正做过任何并发.我偶然发现了这篇博文,并决定制作一个类似(但更简单)的例子:

import os
import threading
import Queue

class Worker(threading.Thread):
    def __init__(self, queue, num):
        threading.Thread.__init__(self)
        self.queue = queue
        self.num = num

    def run(self):
        while True:
            text = self.queue.get()
            #print "{} :: {}".format(self.num, text)
            print "%s :: %s" % (self.num, text)
            self.queue.task_done()

nonsense = ["BLUBTOR", "more nonsense", "cookies taste good", "what is?!"]
queue = Queue.Queue()

for i in xrange(4):
    # Give the worker the queue and also its "number"
    t = Worker(queue, i)
    t.setDaemon(True)
    t.start()

for gibberish in nonsense:
    queue.put(gibberish) …
Run Code Online (Sandbox Code Playgroud)

python multithreading output

4
推荐指数
2
解决办法
1265
查看次数

斐波纳契数的数据类型

由于我正在学习C#,我做了一个小程序来计算X的斐波那契数量.然而,随着数字迅速变大,即使是无符号长数也不能保持数字.我该如何解决这个问题?制作我自己的超大整数数据类型?

c# types numbers fibonacci

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

标签 统计

python ×2

c# ×1

cmd ×1

editor ×1

fibonacci ×1

go ×1

linux ×1

multithreading ×1

numbers ×1

output ×1

pyside ×1

qt ×1

types ×1

user-interface ×1