谁能在下面的代码中告诉为什么“ C”从项目名称中剥离?我有输出和预期的输出”
输入:-
Total: %d 2
TRAINBUILD: macOSfuture
PROJECT: projectDrivercompNIC
TAG: projectDrivercompNIC-1401
SHA: 5f6cc81d
<change://problem/4046817> title1
<change://problem/4135645> title2
Total: %d 12
输出:
projectDrivercompNI
期望的输出:
projectDrivercompNIC
代码:-
import sys,re
with open(sys.argv[1]) as f:
lines = f.read().splitlines()
project = ""
radar_count = ""
new_project = ""
for line in lines:
#print "line:" + line
if re.match(r'PROJECT:\s*.*', line):
project = line.strip(r'^PROJECT:\s*')
project = project.strip()
#print project
#print "project:" + project
if re.match(r'Total: %d\s(\d+)',line):
radar_count = line.strip('Total: %d')
radar_count = radar_count.strip()
#print radar_count
if radar_count !='0' and radar_count != "" and project != new_project :
new_project = project
print new_project