본문 바로가기
Python

[python] def 뒤에 -> 의미

by Leunco 2021. 9. 12.
def to_hex(image_id) -> str:
    return '{0:0{1}x}'.format(image_id, 16)

 

def 뒤에 ->가 오는 이유는 return이 어떤 값인지 알려주기 위해 사용한다.

위의 경우는 -> str이 적혀있기 때문에, string 형태로 반환한다.

 

출처 : https://wotres.tistory.com/entry/def-%EB%92%A4%EC%97%90-None-%EB%98%90%EB%8A%94-str-%EC%9D%98%EB%AF%B8

 

반응형

'Python' 카테고리의 다른 글

[백준] 2798번 : 블랙잭  (0) 2021.12.06
[백준] 2920번: 음계  (0) 2021.12.06
[Tensorflow] 텐서플로우 버전 확인 + 설치  (0) 2021.10.24
[공유] tensorflow 자연어 처리  (0) 2021.10.23
Colab에서 파일 불러오는 방법  (0) 2021.10.19

댓글