Python

[python] def 뒤에 -> 의미

Leunco 2021. 9. 12. 21:02
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

 

반응형