편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2022.06.29

    파이썬에서 값들이 딕셔너리 형태로 나옵니다. 여기서 len 함수를 써서 가장 큰 수를 뽑고 싶은데 어떻게 해야할까요?


    파이썬에서 원하는 값을 뽑기위해 코딩중 입니다.. 우선 c,r에 값을 지정해 두고 shot_list에 append 하였습니다 그리고 여기서 가장 큰 수를 확인하기 위해 print(len(set(shot_list)))을 사용하였고 값들이 수없이 나오는데 하기와 같이 다른 줄로 나옵니다

    ex : 
    3
    3
    3
    4
    5
    6
    

    여기서 단순히 print(set(shot_list)) 을 사용하면 딕셔너리{} 형태로 나오구요.. 가장 큰 len값을 뽑기 위해서 print(max(len(set(shot_list)))) 를 하면 TypeError: 'int' object is not iterable 에러가 발생합니다.

    하고싶은것은 len 함수중에서 가장 큰 수만 뽑고 싶습니다 ex예에서는 6 1개만 가져오고 싶습니다. 어떻게 해아할까요?

        shot_list = []
        mesp_list = []
        real_shot_list = []
        try:
            grid_origin = int(xml_gridshape.find('.//A').text)
        except:
            grid_origin = 0
        xml_measrslts = tree.findall('.//B/C')
        for xml_measrslt in xml_measrslts:
            #axis = int(xml_measrslt.attrib['D'])
            xml_egaphases = xml_measrslt.findall('.//E/F/G/H')
         #H mapのみ
            for elem in xml_egaphases:
                if elem.attrib['I'] == '2':
                    xml_egaphase = elem
        shots = xml_egaphase.findall('.//J/K')
        for shot in shots:
            c, r = float(shot.find('.//L/C').text), float(shot.find('.//L/R').text)
            sx, sy = float(shot.find('.//M/X').text), float(shot.find('.//M/Y').text)
            mx, my = float(shot.find('.//N/X').text), float(shot.find('.//N/Y').text)
            d = str(c)+','+str(r)
            shot_list.append(len(d))
    
            # print(len(set(shot_list)))
            print(max(shot_list))
    
    
  • 프로필 임섭님의 편집
    날짜2022.06.29

    파이썬에서 값들이 딕셔너리 형태로 나옵니다. 여기서 len 함수를 써서 가장 큰 수를 뽑고 싶은데 어떻게 해야할까요?


    파이썬에서 원하는 값을 뽑기위해 코딩중 입니다.. 우선 c,r에 값을 지정해 두고 shot_list에 append 하였습니다 그리고 여기서 가장 큰 수를 확인하기 위해 print(len(set(shot_list)))을 사용하였고 값들이 수없이 나오는데 하기와 같이 다른 줄로 나옵니다 ex : 3 3 3 4 5 6 여기서 단순히 print(set(shot_list)) 을 사용하면 딕셔너리{} 형태로 나오구요.. 가장 큰 len값을 뽑기 위해서 print(max(len(set(shot_list)))) 를 하면 TypeError: 'int' object is not iterable 에러가 발생합니다.

    하고싶은것은 len 함수중에서 가장 큰 수만 뽑고 싶습니다 ex예에서는 6 1개만 가져오고 싶습니다. 어떻게 해아할까요..?

                shot_list = []
                mesp_list = []
                real_shot_list = []
                try:
                    grid_origin = int(xml_gridshape.find('.//A').text)
                except:
                    grid_origin = 0
                xml_measrslts = tree.findall('.//B/C')
                for xml_measrslt in xml_measrslts:
                    #axis = int(xml_measrslt.attrib['D'])
                    xml_egaphases = xml_measrslt.findall('.//E/F/G/H')
                 #H mapのみ
                    for elem in xml_egaphases:
                        if elem.attrib['I'] == '2':
                            xml_egaphase = elem
                shots = xml_egaphase.findall('.//J/K')
                for shot in shots:
                    c, r = float(shot.find('.//L/C').text), float(shot.find('.//L/R').text)
                    sx, sy = float(shot.find('.//M/X').text), float(shot.find('.//M/Y').text)
                    mx, my = float(shot.find('.//N/X').text), float(shot.find('.//N/Y').text)
                    d = str(c)+','+str(r)
                    shot_list.append(len(d))
    
                    # print(len(set(shot_list)))
                    print(max(shot_list))
    
    
  • 프로필 nowp님의 편집
    날짜2022.06.29

    파이썬에서 값들이 딕셔너리 형태로 나옵니다. 여기서 len 함수를 써서 가장 큰 수를 뽑고 싶은데 어떻게 해야할까요?


    파이썬에서 원하는 값을 뽑기위해 코딩중 입니다.. 우선 c,r에 값을 지정해 두고 shot_list에 append 하였습니다 그리고 여기서 가장 큰 수를 확인하기 위해 print(len(set(shot_list)))을 사용하였고 값들이 수없이 나오는데 하기와 같이 다른 줄로 나옵니다

    ex : 
    3
    3
    3
    4
    5
    6
    

    여기서 단순히 print(set(shot_list)) 을 사용하면 딕셔너리{} 형태로 나오구요. 가장 큰 len값을 뽑기 위해서 print(max(len(set(shot_list)))) 를 하면 TypeError: 'int' object is not iterable 에러가 발생합니다.

    하고싶은것은 len 함수중에서 가장 큰 수만 뽑고 싶습니다 ex예에서는 6 1개만 가져오고 싶습니다. 어떻게 해아할까요..?

        shots = xml_egaphase.findall('.//A/B')
        for shot in shots:
            c, r = float(shot.find('.//C/C').text), float(shot.find('.//C/R').text)
            sx, sy = float(shot.find('.//D/X').text), float(shot.find('.//D/Y').text)
            mx, my = float(shot.find('.//Z/X').text), float(shot.find('.//Z/Y').text)
            d = str(c)+','+str(r)
            shot_list.append(d)
            print(max(len(set(shot_list))))
    
    
  • 프로필 임섭님의 편집
    날짜2022.06.29

    파이썬에서 값들이 딕셔너리 형태로 나옵니다. 여기서 len 함수를 써서 가장 큰 수를 뽑고 싶은데 어떻게 해야할까요?


    파이썬에서 원하는 값을 뽑기위해 코딩중 입니다.. 우선 c,r에 값을 지정해 두고 shot_list에 append 하였습니다 그리고 여기서 가장 큰 수를 확인하기 위해 print(len(set(shot_list)))을 사용하였고 값들이 수없이 나오는데 하기와 같이 다른 줄로 나옵니다 ex : 3 3 3 4 5 6 여기서 단순히 print(set(shot_list)) 을 사용하면 딕셔너리{} 형태로 나오구요.. 가장 큰 len값을 뽑기 위해서 print(max(len(set(shot_list)))) 를 하면 TypeError: 'int' object is not iterable 에러가 발생합니다.

    하고싶은것은 len 함수중에서 가장 큰 수만 뽑고 싶습니다 ex예에서는 6 1개만 가져오고 싶습니다. 어떻게 해아할까요..?

                shots = xml_egaphase.findall('.//A/B')
                for shot in shots:
                    c, r = float(shot.find('.//C/C').text), float(shot.find('.//C/R').text)
                    sx, sy = float(shot.find('.//D/X').text), float(shot.find('.//D/Y').text)
                    mx, my = float(shot.find('.//Z/X').text), float(shot.find('.//Z/Y').text)
                    d = str(c)+','+str(r)
                    shot_list.append(d)
                    print(max(len(set(shot_list))))