1.从buildlocation获取buildid,这是“\”之后的最后一个单词,在这种情况下是“A1234ABCDE120083.1”
2.获取buildid后,打开一个文件,然后尝试匹配“Engr Label:Data_CRM_PL_177999”行以获得标签名称“Data_CRM_PL_177999”
3.最终输出应该是“Data_CRM_PL_177999”
出于某种原因,我收到以下语法错误..
import re
Buildlocation= '\\umor\locations455\INT\A1234ABCDE120083.1'
Labelgetbuildlabel(Buildlocation)
def getbuildlabel(BuildLocation):
buildid=BuildLocation.split('\')[-1]
Notes=os.path.join(BuildLocation,Buildid + '_notes.txt')
if os.path.exists(Notes):
try:
open(Notes)
except IOError as er:
pass
else:
for i in Notes.splitlines:
if i.find(Engr Label)
label=i.split(:)[-1]
print label//output should be Data_CRM_PL_177999
输出应该是: -
Line looks like below in the file
Engr Label: Data_CRM_PL_177999
语法错误
buildid=BuildLocation.split('\')[-1]
^
SyntaxError: EOL while scanning string literal