小编Iva*_*din的帖子

如何在python 3中将二进制数据写入stdout?

在python 2.x中,我可以这样做:

import sys, array
a = array.array('B', range(100))
a.tofile(sys.stdout)
Run Code Online (Sandbox Code Playgroud)

然而,现在,我得到了一个TypeError: can't write bytes to text stream.我应该使用一些秘密编码吗?

python python-3.x

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

如何使用子进程模块与进程正确交互

我在使用子进程模块重定向另一个程序的stdio时遇到问题.只是从stdout读取导致挂起,并且Popen.communicate()可以工作,但它在读/写后关闭管道.实现这个最简单的方法是什么?

我在Windows上玩这个:

import subprocess
proc = subprocess.Popen('python -c "while True: print \'Hi %s!\' % raw_input()"',
                        shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                        stderr=subprocess.STDOUT)
while True:
    proc.stdin.write('world\n')
    proc_read = proc.stdout.readline()
    if proc_read:
        print proc_read
Run Code Online (Sandbox Code Playgroud)

python subprocess

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

当前node.js c ++插件的路径

我在C++中为node.js编写了一个插件,遇到了一个小问题.我想在我的模块目录中读取配置文件,但无法以通常的方式找到它(__dirname),因为在C++中,全局对象似乎是空的.

有没有正确的方法来做到这一点,还是我需要诉诸黑客?

c++ node.js

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

标签 统计

python ×2

c++ ×1

node.js ×1

python-3.x ×1

subprocess ×1