IndentationError: unexpected indent

조회수 957회
    # 마지막으로 정수 node ID로부터 인간이 읽을 수 있는 문자로의 맵핑을 로드함.
    node_id_to_name = {}
    for key, val in node_id_to_uid.items():
      if val not in uid_to_human:
        tf.logging.fatal('Failed to locate: %s', val)
      name = uid_to_human[val]
      node_id_to_name[key] = name

    return node_id_to_name

  def id_to_string(self, node_id):
    if node_id not in self.node_lookup:
      return ''
    return self.node_lookup[node_id]


def create_graph():
    """저장된 GraphDef 파일로부터 그래프를 생성하고 저장된 값을 리턴함."""
  # Creates graph from saved graph_def.pb.
  with tf.gfile.FastGFile(os.path.join(
      FLAGS.model_dir, 'classify_image_graph_def.pb'), 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
    _ = tf.import_graph_def(graph_def, name='')

File "", line 11 def id_to_string(self, node_id): ^ IndentationError: unexpected indent 라고 오류가 뜨는데 띄어쓰기가 어디에서 잘못됬는지 모르겠습니다. 아! 참고로 Inception-v3 모델(이미지 인식모델)예제의 일부분 코드입니다.

  • (•́ ✖ •̀)
    알 수 없는 사용자

1 답변

  • tab 하고 스페이스하고 혼용하면 안됩니다.

    그리고 대충봐도 indent 가 스페이스 4칸 2칸 다 제각각입니다.

    파이썬은 들여쓰기에 민감한 언어입니다.

    탭을 스페이스 4칸으로 맞추고 작업하세요.

    많이들 사용하는 python ide(wingide, pycharm, pyscripter 등등) 는 source format 기능이 있어 편하게 해결해주는 기능들을 내장하고 있습니다.

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)