1.Getting 마지막 단어가 "A1234ABCDE120083.1는"이 경우는 파일 열기 및
2.After buildid을 받고있는 "\"뒤에있는 buildlocation에서 buildid ENGR 라벨 일치하는을 개방하고 파일, 행 "ENGR 레이블 : Data_CRM_PL_177999"와 일치하는 것을 시도 "Data_CRM_PL_177999"입니다 레이블 이름을 가져
3.Final 출력은 "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
파일 객체에'splitlines - 나는'xreadlines()'또는 보통 파일 객체만을 사용할 수 있다고 생각한다. –
아, 그래. OP는 원래'splitlines'을 사용했는데, 나는 그것을 잡은 것 같지 않습니다. 나는 그것을 편집 할 것이다. – Michael0x2a
@Michael - 조건이 예상대로 작동하지 않는 것 같아요. 줄마다 한 줄씩 찾으려고하지 않습니다. notes.txt 파일의 첫 줄에 "Request Date : 11/12/2012 5:22:51 PM" , 출력으로 51PM을 참조하십시오. 줄 입력란에 줄 번호 : if line.find ('Engr Label') : – user1795998