zl程序教程

您现在的位置是:首页 >  后端

当前栏目

python - python中执行shell命令

2023-09-27 14:29:10 时间
import subprocess

cmd_ip = "sed -i '/^cloud_server_ip/ccloud_server_ip = 0.0.0.0' name.txt"
cmd_port = "sed -i -e '/^cloud_server_port/ccloud_server_port = {0}' {1}".format(443,                                                                              
                                                                                  name.txt)
try:
    subprocess.check_call(cmd_ip, shell=True)
    subprocess.check_call(cmd_port, shell=True)
except Exception as e:
    print 'error: ', e