【发布时间】:2018-04-19 14:43:22
【问题描述】:
当我在 python 脚本中执行命令时:
import os
import re
tes=list()
tes=os.system('p4 nc files @=4596830')
for line in tes:
line2=re.findall('//depot/prod/DOT/dev/\w+((?:/\w*)*\.c)',line)
print(line2)
我得到的输出是:
//depot/prod/DOT/dev/freebsd/10/sys/dev/nvme/nvme.c#16 - edit change 4596830 (text)
//depot/prod/DOT/dev/mgmtgateway/src/tables/card.smf#12 - edit change 4596830 (text)
//depot/prod/DOT/dev/ontap/prod/driver/scsi/pmcsas_init.c#81 - edit change 4596830 (text)
TypeError: 'int' object has no attribute '__getitem__'
但我只需要以 .c 扩展名结尾的文件:
/freebsd/10/sys/dev/nvme/nvme.c
/ontap/prod/driver/scsi/pmcsas_init.c
【问题讨论】:
标签: python python-2.7 subprocess os.system