os.system (old python) and arguments with parameters

余生颓废 提交于 2019-12-11 08:19:02

问题


I trying to write simple code that execute os command with parameters

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os

target = "i586"

build = os.system('/usr/bin/hsh --target="target"')

But it always start as /usr/bin/hsh --target=target instead of target=i586. Also subprocess.call not working cause python too old.

Please help me.


回答1:


build = os.system('/usr/bin/hsh --target="%s"' % target)

or

build = os.system('/usr/bin/hsh --target="' + target + '"')


来源:https://stackoverflow.com/questions/9768529/os-system-old-python-and-arguments-with-parameters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!