TypeError :-: 'instance'및 'float'에 대해 지원되지 않는 피연산자 유형

Wilsonwatson

이 코드는 전체를 게시하기에는 너무 길어서 문제가이 루프에 포함되기를 바랍니다.하지만 여기서 무엇이 잘못되었는지에 대해 정말 혼란 스럽습니다. 이 루프가 있습니다.

 if index == 1:
         mag_diffs = []
         counter = 0

         while (image_objects[counter].magr_value > -6.0) and (image_objects[counter].magr_value < -4.0) and (counter < 5):
             mag_diff = (image_objects[counter].magr_value - new_s_objects[counter].magr)
             print 'mag_diff is:'
             print mag_diff
             mag_diffs.append(mag_diff)
             counter +=1


         mag_diffs.sort()
         mag_offset = np.median(mag_diffs)

여기에서 호출하려고 할 때 나중에 코드에서 오류가 발생합니다.

 sextractor_mr.append((new_s_objects[index].magr + mag_offset))

이 오류가 발생합니다.

Traceback (most recent call last):
  File "sextractor_reader.py", line 272, in <module>
    sextractor_mr.append((new_s_objects[index].magr + mag_offset))
IndexError: list index out of range

하지만 while 루프 조건이 결코 충족되지 않는다는 것을 알아 냈습니다 (5 번이어야 함). 그래서 while 루프를 주석 처리하고 들여 쓰기를 제거하면 while 루프에있는 것을 한 번만 수행합니다. 이 오류가 발생합니다.

Traceback (most recent call last):
  File "sextractor_reader.py", line 252, in <module>
    mag_diff = (image_objects[counter].magr_value - new_s_objects[counter].magr)
TypeError: unsupported operand type(s) for -: 'instance' and 'float'

오류 메시지를 찾으려고했지만 내 상황과 비슷한 것을 찾지 못했습니다. 저는 수업이별로 편하지 않아서 수업과 관련이 있다고 생각합니다. 바라건대 오류가 내가 준 내용에 포함되어 있지만 코드가 너무 길어서 모든 것을 게시 할 수 없습니다 (예 : 1000 줄).

편집 : 좋아 내가 여기에있는 것이 잘못되었습니다. if 문 위에 image_objects [0] .magr_value를 인쇄하고 반환했습니다.

<__main__.SDSS_object instance at 0x10bd4d7a0>

내가 원하는 것은 전혀 아닙니다. 값이있는 플로트를 원합니다. 그래도 수업을 부르는 방법이라고 생각했습니다.

CrazyCasta

구체적인 내용을 알려 드리기 위해 더 자세한 정보를 제공해야하지만 오류 메시지를 해독 해 드릴 수 있습니다. 그것은 image_objects[counter].magr_value숫자 유형이 아니라는 것을 알려줍니다 . instance숫자를 뺄 수없는 다른 유형 ( 특히)입니다. Yu Hao가 지적한 것처럼, 우리는 당신을 더 도울 완전한 예가 필요합니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

TypeError :-: 'Approximate'및 'float'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError :-: 'float'및 'method'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : + : 'Timestamp'및 'float'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : + : 'int'및 'instance'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

지원되지 않는 목록 TypeError : / : 'list'및 'float'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : & : 'float'및 'float'에 대해 지원되지 않는 피연산자 유형이지만 &가 없습니다.

분류에서Dev

Python : / : 'tuple'및 'float'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

Python 3 : / : 'float'및 'bytes'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

/에 대해 지원되지 않는 피연산자 유형 : 'instance'및 'int'

분류에서Dev

Python : TypeError : + : 'NoneType'및 'int'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError :-에 대해 지원되지 않는 피연산자 유형 : 'Position'및 'Position'

분류에서Dev

TypeError : +에 대해 지원되지 않는 피연산자 유형 : 'NoneType'및 'list'

분류에서Dev

TypeError : + =에 대해 지원되지 않는 피연산자 유형 : 'int'및 'list'with Pygame

분류에서Dev

TypeError : %에 대해 지원되지 않는 피연산자 유형 : 'NoneType'및 'int'

분류에서Dev

TypeError : % : 'Text'및 'tuple'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : | : 'list'및 'list'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : +에 대해 지원되지 않는 피연산자 유형 : 'int'및 'str'값

분류에서Dev

+ : 'dict'및 'int'에 대해 Django TypeError 지원되지 않는 피연산자 유형

분류에서Dev

TypeError :-: 'tuple'및 'tuple'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : * : 'int'및 'NoneType'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : << : 'int'및 'float'에 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : / : 'NoneType'및 'float'에 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : 'Instance'및 'Int'에 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : 'float'개체를 str 암시 적으로 변환 할 수 없거나 TypeError :-: 'str'및 'float'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

지원되지 않는 피연산자 유형 'int'및 'list'에 대한 TypeError

분류에서Dev

두 개의 float가 TypeError를 throw합니다. + : 'float'및 'str'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TypeError : ** 또는 pow ()에 대해 지원되지 않는 피연산자 유형 : '함수'및 'int'확률 계산기

분류에서Dev

scikit 학습 오류-100. * self.contamination) TypeError : * : 'float'및 'type'에 대해 지원되지 않는 피연산자 유형

분류에서Dev

TyperError :-: 'float'및 'builtin_function_or_method'에 대해 지원되지 않는 피연산자 유형

Related 관련 기사

  1. 1

    TypeError :-: 'Approximate'및 'float'에 대해 지원되지 않는 피연산자 유형

  2. 2

    TypeError :-: 'float'및 'method'에 대해 지원되지 않는 피연산자 유형

  3. 3

    TypeError : + : 'Timestamp'및 'float'에 대해 지원되지 않는 피연산자 유형

  4. 4

    TypeError : + : 'int'및 'instance'에 대해 지원되지 않는 피연산자 유형

  5. 5

    지원되지 않는 목록 TypeError : / : 'list'및 'float'에 대해 지원되지 않는 피연산자 유형

  6. 6

    TypeError : & : 'float'및 'float'에 대해 지원되지 않는 피연산자 유형이지만 &가 없습니다.

  7. 7

    Python : / : 'tuple'및 'float'에 대해 지원되지 않는 피연산자 유형

  8. 8

    Python 3 : / : 'float'및 'bytes'에 대해 지원되지 않는 피연산자 유형

  9. 9

    /에 대해 지원되지 않는 피연산자 유형 : 'instance'및 'int'

  10. 10

    Python : TypeError : + : 'NoneType'및 'int'에 대해 지원되지 않는 피연산자 유형

  11. 11

    TypeError :-에 대해 지원되지 않는 피연산자 유형 : 'Position'및 'Position'

  12. 12

    TypeError : +에 대해 지원되지 않는 피연산자 유형 : 'NoneType'및 'list'

  13. 13

    TypeError : + =에 대해 지원되지 않는 피연산자 유형 : 'int'및 'list'with Pygame

  14. 14

    TypeError : %에 대해 지원되지 않는 피연산자 유형 : 'NoneType'및 'int'

  15. 15

    TypeError : % : 'Text'및 'tuple'에 대해 지원되지 않는 피연산자 유형

  16. 16

    TypeError : | : 'list'및 'list'에 대해 지원되지 않는 피연산자 유형

  17. 17

    TypeError : +에 대해 지원되지 않는 피연산자 유형 : 'int'및 'str'값

  18. 18

    + : 'dict'및 'int'에 대해 Django TypeError 지원되지 않는 피연산자 유형

  19. 19

    TypeError :-: 'tuple'및 'tuple'에 대해 지원되지 않는 피연산자 유형

  20. 20

    TypeError : * : 'int'및 'NoneType'에 대해 지원되지 않는 피연산자 유형

  21. 21

    TypeError : << : 'int'및 'float'에 지원되지 않는 피연산자 유형

  22. 22

    TypeError : / : 'NoneType'및 'float'에 지원되지 않는 피연산자 유형

  23. 23

    TypeError : 'Instance'및 'Int'에 지원되지 않는 피연산자 유형

  24. 24

    TypeError : 'float'개체를 str 암시 적으로 변환 할 수 없거나 TypeError :-: 'str'및 'float'에 대해 지원되지 않는 피연산자 유형

  25. 25

    지원되지 않는 피연산자 유형 'int'및 'list'에 대한 TypeError

  26. 26

    두 개의 float가 TypeError를 throw합니다. + : 'float'및 'str'에 대해 지원되지 않는 피연산자 유형

  27. 27

    TypeError : ** 또는 pow ()에 대해 지원되지 않는 피연산자 유형 : '함수'및 'int'확률 계산기

  28. 28

    scikit 학습 오류-100. * self.contamination) TypeError : * : 'float'및 'type'에 대해 지원되지 않는 피연산자 유형

  29. 29

    TyperError :-: 'float'및 'builtin_function_or_method'에 대해 지원되지 않는 피연산자 유형

뜨겁다태그

보관