[공부용]참고 사이트 모음/[python]

[python] def 뒤에 -> None 또는 -> str 의미

bled 2021. 1. 14. 16:48

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

 

def 뒤에 -> None 또는 -> str 의미

파이썬 코드를 보다보면 def 펑션 뒤에 -> None 또는 -> str 로 명시된 경우가 있다. > def test(self, a) -> None: print(a) > def test2(self, a) -> str: return '이 펑션은 : ' + 'a' 이렇게 적어주는 경우는..

wotres.tistory.com

파이썬 코드를 보다보면 def 펑션 뒤에 -> None 또는 -> str 로 명시된 경우가 있다.

def test(self, a) -> None:
    print(a)



def test2(self, a) -> str:
    return '이 펑션은 : ' + 'a'

이렇게 적어주는 경우는 리턴값이 어떠한 상태인지를 명시해주기 위해 사용한다.