小编Mih*_*hir的帖子

找不到函数的定义 - VSCode Python

我正在使用 VSCode for Python 以及在 VSCode 中启用的 Microsoft for Python 扩展。

对于Python v3.9.0,如果我尝试寻找函数定义,我会得到No definition found

在此处输入图片说明

但是,如果我将 Conda Virtual 环境用于 Python 3.7.0,则不会出现错误

可能是什么问题?

python visual-studio-code

5
推荐指数
2
解决办法
9771
查看次数

如何在 VSCode 中运行 MATLAB (.m) 文件?

我无法弄清楚如何在 VSCode 中运行 MATLAB (.m) 代码。

我已经为 VSCode安装了MATLAB 扩展,并添加了扩展中所述的MATLABmlint文件的路径。

"matlab.mlintpath"
Run Code Online (Sandbox Code Playgroud)

VSCode 将该文件标识为 MATLAB 文件。但是,代码不会运行。

如何从 VSCode 中运行 MATLAB 代码?

matlab visual-studio-code

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

在 Python 的嵌套函数中使用全局变量

我读了这段代码(下面给出),我的理解是,如果一个变量在函数内被声明为 global 并且如果它被修改,那么它的值将永久改变。

x = 15
def change(): 
    global x 
    x = x + 5
    print("Value of x inside a function :", x) 
change() 
print("Value of x outside a function :", x)  
Run Code Online (Sandbox Code Playgroud)

输出:

Value of x inside a function : 20
Value of x outside a function : 20
Run Code Online (Sandbox Code Playgroud)

但下面的代码显示了不同的输出。x 的值如何在里面没有改变print("After making change: ", x) 并且仍然保持 15

def add(): 
    x = 15
    
    def change(): 
        global x 
        x = 20
    print("Before making changes: ", x) 
    print("Making change") 
    change() …
Run Code Online (Sandbox Code Playgroud)

python nested global function

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

标签 统计

python ×2

visual-studio-code ×2

function ×1

global ×1

matlab ×1

nested ×1