小编h_e*_*k_a的帖子

FileNotFoundError: [WinError 2] 系统找不到指定的文件

我目前正在学习如何使用该模块,subprocess而且我刚刚开始阅读我的新书。立即,我收到了一条我不明白的错误消息。

Traceback (most recent call last):
  File "D:/me/Python/subprocess.py", line 3, in <module>
    proc = subprocess.Popen(['echo', 'Hello there'], stdout=subprocess.PIPE)
  File "C:\Python34\lib\subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "C:\Python34\lib\subprocess.py", line 1112, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system can't find the specified file
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚这里出了什么问题

import subprocess

proc = subprocess.Popen(['echo', 'Hello there'], stdout=subprocess.PIPE)
out, err = proc.communicate()
print(out.decode('utf-8'))
Run Code Online (Sandbox Code Playgroud)

在书中他们说这段代码应该在屏幕上打印“Hello there”,但由于某种原因,它没有。

这里有什么问题?如果对您有帮助,我目前正在使用 python 3.4.3。

python subprocess python-3.x

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

求解线性方程组.使用numpy的三个变量

我目前需要一个类,它必须能够显示和解决像这样的方程系统:

| 2x-4y+4z=8  |
| 34x+3y-z=30 |
| x+y+z=108   |
Run Code Online (Sandbox Code Playgroud)

我认为编写一个类来将eqation系统的左侧事物转换为类似矩阵的对象是个好主意,这里是这个系统的自制矩阵:

/2  -4  4\
|34 3  -1|
\1  1   1/
Run Code Online (Sandbox Code Playgroud)

我目前写了这个:

class mymatrix(object):
    def __init__(self):
        o11 = None
        o12 = None
        o12 = None
        o21 = None
        o22 = None
        o23 = None
        o31 = None
        o32 = None
        o33 = None

    def set(row, column, value):
        string = 'o'+str(row)+str(column)+' = '+str(value)
        exec(string)

    def solve(self, listwithrightsidethings):
        #Here I want to solve the system. This code should read  the three    
        #values out …
Run Code Online (Sandbox Code Playgroud)

python numpy linear-algebra equation-solving python-3.x

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

如何在Python中调用多级嵌套函数?

我正在尝试学习Python,并且对Python中的多级嵌套函数和函数闭包很少有疑问.请帮助我了解这将如何工作.

以下代码中的问题:

  1. 如何从主块调用func3?
  2. func3是否可以从func1访问x1,或者只是从func2的直接封闭范围访问x2?

示例代码:

# File: nesteFunc.py
def func1():
    x1 = 1
    def func2():
        x2 = 2
        def func3():
            x3 = 3
            print(x1, x2, x3)
        return func3

if __name__ == "__main__":
    f = func1()
    f()            # line 14
Run Code Online (Sandbox Code Playgroud)

上面的代码给了我这个错误信息:

Traceback (most recent call last):
  File "D:/Python Prep/nestedFunc", line 14, in <module>
    f()
TypeError: 'NoneType' object is not callable

Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud)

python function python-3.x

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