혹시 for문에서 이미 지나간 인자값에 대한 접근을 어떻게 하나요??

34 views
Skip to first unread message

qwerty

unread,
Mar 10, 2016, 12:17:28 AM3/10/16
to Python 3 질문 게시판
코멘트는 여러가지 데이터가 담긴 형태의 리스트(?) 형태입니다.

comment ={ {'id'=1234,'no'=2134,'data'='abcd'},
                     {'id'=2345,'no'=1231,'data'='cdef'}}
 
이런 형태입니다.


사실상 정확히 말하자면 저기 안에 들어있는 comment의 type는 
sqlalchemy.util.__collections__.result값입니다.



for comment in comments:
    if comment['id']==(이전 comment에 들어있는 id값)
         #코드 ....


이런식으로 되있다면 이전에 담겨있는 comment의 id값을 어떤식으로 접근할수 있을까요?...

C언어 같은 경우에는 항상 배열의 위치를 i값을 따로 줘서 접근할수 있었는데 파이썬에서는 어떻게 접근해야 하는지 모르겠네요...

for(int i;i<20;i++){
    arr[i]==arr[i-1]
}

도와주세요 ㅠㅠ
Reply all
Reply to author
Forward
0 new messages