小编Dom*_*nik的帖子

有没有办法在 Visual Studio Code 中删除 Jupyter“运行单元格”语法?

我想删除 Jupyter“运行单元格|运行所有单元格”注释,如果 Visual Studio 代码中存在语法 #%%,则会出现该注释。

VSC

有没有控制它的设置?

谢谢你。

python visual-studio-code jupyter-notebook

10
推荐指数
2
解决办法
2306
查看次数

远程运行命令的 Python Fabric 返回值

我正在使用 python Fabric 中的 run 命令远程执行脚本。

C = fabric.Connection('ip', user='user', connect_kwargs={"password": "password"})
try:
   r = C.run('python3 ~/script.py')
   if r:
        print('{} SUCCESS'.format(C.host))
        break
   else:
        print('{} ERROR'.format(C.host))
        break
except:
    print('{} ERROR'.format(C.host))
Run Code Online (Sandbox Code Playgroud)

我的 script.py 是:

def download_file(url, filename):
    try:
        response = requests.get(url)
        # Open file and write the content
        with open(filename, 'wb') as file:
            # A chunk of 128 bytes
            for chunk in response:
                file.write(chunk)
        return 1
    except requests.exceptions.RequestException as e:
        return 0

download_file(url,filename)
Run Code Online (Sandbox Code Playgroud)

当我执行 run 命令时,有没有办法查看我的函数中返回了哪个值,1 还是 0?

谢谢你!

python linux remote-access fabric

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