by Devin Yang

建立于: 6年前 ( 更新: 6年前 )

最简化版本的Python系统命令运行范本

#!/usr/local/bin/python3
# -*- coding: utf-8 -*-
from subprocess import Popen, PIPE, STDOUT
#运行的命令
command='ls -l'.split()
proc=Popen(command , stdout=PIPE,stderr=PIPE, universal_newlines=True);
output, error = proc.communicate()

#显示运行结果
if(proc.poll()==0):
     print(output)
else:
     print("{} Error\n".format(error))


 

Tags:

Devin Yang

文章内容无法一一说明,如果您有什么不了解处,欢印提问哦:)

No Comment

Post your comment

需要登入才可留言!

类似文章


linux, python, colab

如何从我们的Server透过ssh连线到colab?

介绍我写的一支bash,用来透过ssh连线到colab vm内。 一行命令,搞定colab OpenSSH Server。

certbot,docker,ftp

curlftpfs介绍及手动证书申请

情境分享,设想您有WebHosting,他只提供FTP连线,然后您想手动的方式申请证书。在本篇分享我如何使用Docker安装curlftpfs,并且挂载远程主机FTP数据夹,然后在容器内运行certbot申请SSL证书。撇除证书申请不说,我初次发觉到curlftpfs这个命令时,觉的满有意思的,特别是如果你用的是MacOS用户,手边没有一个满意的FTP软体时。您跟我一样喜欢在命令行上打滚,或许您应该也会喜欢这个命令。🤭

javascript

介绍document.designMode

document.designMode,可以控制整个document变为可编辑的。 我们透过"on"及"off"来调整。 透过document.execCommand我们能做很多事情,例如:insertText。