我试图获取标签的日期。该cmd
命令,我知道的是:使用python和p4v获取标签的日期
p4 labels -e the_label_name
的确实给了我下面的:
Label the_label_name 2014/06/05 00:05:13 'Created by mebel. '
使用Python,我写道:
os.system("sc labels -t -e the_label_name")
什么,我得到的是:
Label the_label_name 2014/06/05 00:05:13 'Created by mebel. '
0
但是,如果我写
label = os.system("sc labels -t -e the_label_name")
我得到
label = 0
你知道我缺少什么?
正如你的第一个例子清楚显示的那样,'os.system'调用的返回值是'0'。这被分配给'label'。根据[文档](https://docs.python.org/2/library/os.html#os.system),如果您想要检索进程的结果,请考虑使用'subprocess'。 – jonrsharpe
考虑使用P4Python库;它使脚本Perforce调用更容易。 –
您也可以使用-G全局选项,该选项可以将所有输出(以及带有-i的表单命令的批量输入)格式化为封送Python字典对象,这在脚本编写时最常使用。请参阅http://www.perforce.com/perforce/doc.current/manuals/cmdref/global.options.html。 –