안녕하세요, 아래의 모든 코드를 통해 데이터에서 특정 정보를 추출 할 수있게되었습니다. 누군가가 이것을 사용하여 더 적절하게 쓸 수있게 도와 주길 바랍니다. 많은 선 지금 난 단지이 실제로 더 나은 for
loop로 이루어집니다"While()"을 파이썬에서 사용하는 방법
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
tableau = []
data = "00:02:12.935 mta Messages I Doc O:NVS:FAXG3/ R:NVS:SMTP.0/[email protected] mid:6499"
result1 = {}
i = re.findall(r"^.[^\ ]*", data)
j = re.findall(r"\d+$", data)
k = re.findall(r"O:[^\ ]*", data)
r = re.findall(r"R:[^\ ]*", data)
result1 = {'Heure':i,'MID':j,'Source':k,'Destination':r}
data = "00:03:12.935 mta Messages I Doc O:NVS:FAXG3/ R:NVS:SMTP.0/[email protected] mid:6599"
result2 = {}
i = re.findall(r"^.[^\ ]*", data)
j = re.findall(r"\d+$", data)
k = re.findall(r"O:[^\ ]*", data)
r = re.findall(r"R:[^\ ]*", data)
result2 = {'Heure':i,'MID':j,'Source':k,'Destination':r}
tableau.append(result1)
tableau.append(result2)
print tableau
while while은 Python 키워드이므로 "While()'"기능은 없습니다. (또한 특정 데이터 집합을 반복 할 때 'for' 루프를 원할 것입니다.) – geoffspear
'while '은 여러분이 원하는 것이라고 생각하지 않습니다. 내가 이해하는 바와 같이 일반적으로 문자열 목록으로 '데이터'를 갖게됩니다. 그런 경우에 'for..in ..'루프를 사용하십시오. – sashkello
질문을 명확히하십시오 - 반복 할 내용이 명확하지 않습니다. – sashkello