【发布时间】:2013-09-06 09:56:32
【问题描述】:
我尝试编写一个包含 bash 命令的函数。我想将命令的输出分配给我的python中的变量 我的意思是,函数 gitCheck 找到我的 git Repository 的目录并将其分配给 gitRep 但它只给我 0。有没有人知道我该怎么做?提前致谢
def gitCheck():
reference_repositories_path="cat $HOME/.git_reference_repositories | sed 's/GIT_REFERENCES_PATH=//'"
gitRep=os.system(reference_repositories_path)
print gitRep
输出
应该是/home/gwapps/Desktop/GIT_REFERENCE_REPOSITORIES
但它给了我0
【问题讨论】: